Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

POST: Workspace Item using restapi in C#.net 500-Internal Server Error

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
Anonymous
4571 Views, 15 Replies

POST: Workspace Item using restapi in C#.net 500-Internal Server Error

Anonymous
Not applicable

Hi,

 

I am using RestAPi to post items under workspace from Sql Server database.

I am using the same format explained in the documentation. But whenever I use POST method I am getting 500-Internal Server Error.

I even tried to test this API in postman also. But getting the same 500-internal server error. 

I am able to read the data using GET .But POST is not working.

Do I need to have more permissions to POST items? 

If you have any example please post. 

 

Thanks in advance,

 

0 Likes

POST: Workspace Item using restapi in C#.net 500-Internal Server Error

Hi,

 

I am using RestAPi to post items under workspace from Sql Server database.

I am using the same format explained in the documentation. But whenever I use POST method I am getting 500-Internal Server Error.

I even tried to test this API in postman also. But getting the same 500-internal server error. 

I am able to read the data using GET .But POST is not working.

Do I need to have more permissions to POST items? 

If you have any example please post. 

 

Thanks in advance,

 

15 REPLIES 15
Message 2 of 16
dany.poudrier
in reply to: Anonymous

dany.poudrier
Alumni
Alumni

Hi,

 

If you don't mind giving us more details, like the json content and perhaps a screenshot of your postman config, it would greatly help in analyzing your issue.



Dany Poudrier

PLM Product Manager
0 Likes

Hi,

 

If you don't mind giving us more details, like the json content and perhaps a screenshot of your postman config, it would greatly help in analyzing your issue.



Dany Poudrier

PLM Product Manager
Message 3 of 16
Anonymous
in reply to: dany.poudrier

Anonymous
Not applicable

Hi,

 

Thanks for the response. Please find the attached postman screenshot. Also below is the code. I am using C#.net and i'm not using Json format.

 

 

public XmlDocument POSTWorksapcesitems()
{
if (!_loggedIN) { return null; }

XmlDocument xmlDoc = new XmlDocument();
Properties obj = new Properties();
List<items> itemlist = new List<items>();
items new1 = new items();
new1.key = "BRAND";
new1.value = "TEST";
itemlist.Add(new1);

metafields meta = new metafields();
meta.itemsobj = itemlist;

List<metafields> metaobj = new List<metafields>();

metaobj.Add(new metafields() { itemsobj = itemlist });
//{"key":"BRAND","fieldData":{"value":"N/A","formattedValue":"N/A","dataType":"Single Line Text"}
//{"key":"BRAND","fieldData":{"value":"Adidas","formattedValue":"Adidas","dataType":"Single Line Text"}
string RequestUri = _tenantURI + "api/rest/v1/workspaces/54/items";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(RequestUri);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
HttpResponseMessage response = client.PostAsJsonAsync(RequestUri, metaobj).Result;
HttpWebRequest request = getHTTPRequest(_tenantURI + "api/rest/v1/workspaces/54/items.xml", "GET");
// HttpWebRequest request = getHTTPRequest(_tenantURI + "api/rest/v1/workspaces/11/items", "Post");
request.Headers.Add(HttpRequestHeader.Cookie, _authCookie);
HttpWebResponse response1 = (HttpWebResponse)request.GetResponse();
using (XmlReader reader = XmlReader.Create(response1.GetResponseStream(), new XmlReaderSettings() { CloseInput = true }))
{
xmlDoc.Load(reader);
}

return xmlDoc;
}


private HttpWebResponse post(string uri, string payload)
{
XmlDocument doc = new XmlDocument();
HttpWebRequest request = getHTTPRequest(uri, "POST");
request.Headers.Add(HttpRequestHeader.Cookie, _authCookie);

UTF8Encoding encoding = new UTF8Encoding();
request.ContentLength = encoding.GetByteCount(payload);
request.ContentType = "application/xml";

using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(encoding.GetBytes(payload), 0, encoding.GetByteCount(payload));
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

return response;
}

private HttpWebRequest getHTTPRequest(string uri, string method)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = method;
request.Accept = "application/xml";

return request;
}

}

public class itemInsert
{
public string ContentType { get; set; }
public string Author { get; set; }
public string id { get; set; }
}

public class Properties
{
public List<metafields> prop { get; set; }

}
public class metafields
{
public List<items> itemsobj { get; set; }
}

public class items
{
public string key { get; set; }
public string value { get; set; }
}

 

Thanks,

0 Likes

Hi,

 

Thanks for the response. Please find the attached postman screenshot. Also below is the code. I am using C#.net and i'm not using Json format.

 

 

public XmlDocument POSTWorksapcesitems()
{
if (!_loggedIN) { return null; }

XmlDocument xmlDoc = new XmlDocument();
Properties obj = new Properties();
List<items> itemlist = new List<items>();
items new1 = new items();
new1.key = "BRAND";
new1.value = "TEST";
itemlist.Add(new1);

metafields meta = new metafields();
meta.itemsobj = itemlist;

List<metafields> metaobj = new List<metafields>();

metaobj.Add(new metafields() { itemsobj = itemlist });
//{"key":"BRAND","fieldData":{"value":"N/A","formattedValue":"N/A","dataType":"Single Line Text"}
//{"key":"BRAND","fieldData":{"value":"Adidas","formattedValue":"Adidas","dataType":"Single Line Text"}
string RequestUri = _tenantURI + "api/rest/v1/workspaces/54/items";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(RequestUri);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
HttpResponseMessage response = client.PostAsJsonAsync(RequestUri, metaobj).Result;
HttpWebRequest request = getHTTPRequest(_tenantURI + "api/rest/v1/workspaces/54/items.xml", "GET");
// HttpWebRequest request = getHTTPRequest(_tenantURI + "api/rest/v1/workspaces/11/items", "Post");
request.Headers.Add(HttpRequestHeader.Cookie, _authCookie);
HttpWebResponse response1 = (HttpWebResponse)request.GetResponse();
using (XmlReader reader = XmlReader.Create(response1.GetResponseStream(), new XmlReaderSettings() { CloseInput = true }))
{
xmlDoc.Load(reader);
}

return xmlDoc;
}


private HttpWebResponse post(string uri, string payload)
{
XmlDocument doc = new XmlDocument();
HttpWebRequest request = getHTTPRequest(uri, "POST");
request.Headers.Add(HttpRequestHeader.Cookie, _authCookie);

UTF8Encoding encoding = new UTF8Encoding();
request.ContentLength = encoding.GetByteCount(payload);
request.ContentType = "application/xml";

using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(encoding.GetBytes(payload), 0, encoding.GetByteCount(payload));
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

return response;
}

private HttpWebRequest getHTTPRequest(string uri, string method)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = method;
request.Accept = "application/xml";

return request;
}

}

public class itemInsert
{
public string ContentType { get; set; }
public string Author { get; set; }
public string id { get; set; }
}

public class Properties
{
public List<metafields> prop { get; set; }

}
public class metafields
{
public List<items> itemsobj { get; set; }
}

public class items
{
public string key { get; set; }
public string value { get; set; }
}

 

Thanks,

Message 4 of 16
dany.poudrier
in reply to: Anonymous

dany.poudrier
Alumni
Alumni

Hi,

 

Thanks for the information. I will try to see if I can replicate your issue.

 

For the screenshot of postman, I would require the query information, not the result from the server. My goal is to abstract the C# part of your question and make sure that the arguments and headers are correct...

 

So if you could send this info I will be able to help you. Make sure I don't see any passwords in your screenshots 😉



Dany Poudrier

PLM Product Manager
0 Likes

Hi,

 

Thanks for the information. I will try to see if I can replicate your issue.

 

For the screenshot of postman, I would require the query information, not the result from the server. My goal is to abstract the C# part of your question and make sure that the arguments and headers are correct...

 

So if you could send this info I will be able to help you. Make sure I don't see any passwords in your screenshots 😉



Dany Poudrier

PLM Product Manager
Message 5 of 16

dany.poudrier
Alumni
Alumni

Hi,

 

I stumbled into something interesting, don't know if it is related but it seems to fit the case:

 

We have V1 apis and V2 apis.

 

V1 API url are /api/rest/v1/workspaces/54/items

V2 API url are /api/v2/workspaces/54/items

 

On your screenshot you have /api/rest/v2/workspaces/54/items .  The syntax is not correct as you either have a /rest/ too much or a typo to use v1 instead of v2.

 

From your code you are using v1 APIs, so I suggest you try again postman with the right url (/rest/v1/) and see if you can get postman request to work.



Dany Poudrier

PLM Product Manager
0 Likes

Hi,

 

I stumbled into something interesting, don't know if it is related but it seems to fit the case:

 

We have V1 apis and V2 apis.

 

V1 API url are /api/rest/v1/workspaces/54/items

V2 API url are /api/v2/workspaces/54/items

 

On your screenshot you have /api/rest/v2/workspaces/54/items .  The syntax is not correct as you either have a /rest/ too much or a typo to use v1 instead of v2.

 

From your code you are using v1 APIs, so I suggest you try again postman with the right url (/rest/v1/) and see if you can get postman request to work.



Dany Poudrier

PLM Product Manager
Message 6 of 16

dany.poudrier
Alumni
Alumni

Hi,

 

I just tested with a similar setup with postman and got a 201 (Item created).

 

See example below.  It think from your code example you may have missed the metaFields json property when doing your query...

 

response.png

 



Dany Poudrier

PLM Product Manager
0 Likes

Hi,

 

I just tested with a similar setup with postman and got a 201 (Item created).

 

See example below.  It think from your code example you may have missed the metaFields json property when doing your query...

 

response.png

 



Dany Poudrier

PLM Product Manager
Message 7 of 16
Anonymous
in reply to: dany.poudrier

Anonymous
Not applicable

Sorry,

 

I tested v1 which is not working and then I tested v2. Please find the attached screenshot.I am still getting the same error.

 

Thanks,

Suneetha

0 Likes

Sorry,

 

I tested v1 which is not working and then I tested v2. Please find the attached screenshot.I am still getting the same error.

 

Thanks,

Suneetha

Message 8 of 16
tony.mandatori
in reply to: Anonymous

tony.mandatori
Autodesk
Autodesk

I took a look at the server logs and here is what i see.

 

ERROR - Rest Error on /api/rest/v1/workspaces/54/items\ncom.dms.customer.CustomerTransactionException: Error executing customer transaction [customer: BOATECHNOLOGY]\n\tat com.dms.customer.CustomerTransactionRunner.execute(CustomerTransactionRunner.ja...

 

Caused by: com.dms.api.rest2.common.APIException: The request contains no authorization information.
at com.dms.servletFilter.APIAuthorizationFilter.doFilter(APIAuthorizationFilter.java:61)

 

@timestamp   2016-10-13T21:56:56.985Z

 

So I think the issue is related to the way you are authenticating.

 

We usually do a login request in a separate tab.

0 Likes

I took a look at the server logs and here is what i see.

 

ERROR - Rest Error on /api/rest/v1/workspaces/54/items\ncom.dms.customer.CustomerTransactionException: Error executing customer transaction [customer: BOATECHNOLOGY]\n\tat com.dms.customer.CustomerTransactionRunner.execute(CustomerTransactionRunner.ja...

 

Caused by: com.dms.api.rest2.common.APIException: The request contains no authorization information.
at com.dms.servletFilter.APIAuthorizationFilter.doFilter(APIAuthorizationFilter.java:61)

 

@timestamp   2016-10-13T21:56:56.985Z

 

So I think the issue is related to the way you are authenticating.

 

We usually do a login request in a separate tab.

Message 9 of 16
Anonymous
in reply to: tony.mandatori

Anonymous
Not applicable

I do not have any issue when I run the api in the browser and I got the data also. 

 I am trying to POST data using C#.net and  getting 500 Internal Server Error.

Same error I am getting in POSTMAN also. Attached is the screen shot and I sent the c#.net code already.

If you can send us the sample code that would be great helpful. 

 

Thanks,

0 Likes

I do not have any issue when I run the api in the browser and I got the data also. 

 I am trying to POST data using C#.net and  getting 500 Internal Server Error.

Same error I am getting in POSTMAN also. Attached is the screen shot and I sent the c#.net code already.

If you can send us the sample code that would be great helpful. 

 

Thanks,

Message 10 of 16
dany.poudrier
in reply to: Anonymous

dany.poudrier
Alumni
Alumni

Hi,

 

Is it possible that you are missing the login phase in your code?

 

In your C# application, you first need to authenticate to get a sessionid.

 

It seems consistent with the findings from Tony in the logs.

 

You can have a look at the Login and Authentication documentation that will give you the information you need to the endpoint and payload required to first login to the system, get the sessionid and after that add to your request header the cookie information.

 

Here is a small extract of the documentation :

 

 

Request header

To authenticate each request sent to the server after initial login, send the following in the header of the request:

 

Cookie: customer=[CUSTOMERTOKEN];JSESSIONID[sessionid]

Replace [CUSTOMERTOKEN] and [sessionid] respectively with the sessionid and customerToken values captured from the POST Login response.



Dany Poudrier

PLM Product Manager
0 Likes

Hi,

 

Is it possible that you are missing the login phase in your code?

 

In your C# application, you first need to authenticate to get a sessionid.

 

It seems consistent with the findings from Tony in the logs.

 

You can have a look at the Login and Authentication documentation that will give you the information you need to the endpoint and payload required to first login to the system, get the sessionid and after that add to your request header the cookie information.

 

Here is a small extract of the documentation :

 

 

Request header

To authenticate each request sent to the server after initial login, send the following in the header of the request:

 

Cookie: customer=[CUSTOMERTOKEN];JSESSIONID[sessionid]

Replace [CUSTOMERTOKEN] and [sessionid] respectively with the sessionid and customerToken values captured from the POST Login response.



Dany Poudrier

PLM Product Manager
Message 11 of 16
Anonymous
in reply to: dany.poudrier

Anonymous
Not applicable

Hi,

 

As I mentioned in the first email I do not have any  issues to login and GET the data. I am getting error when POSTing the data only.In the previous email I sent only POST method.

 

Thanks,

Suneetha

0 Likes

Hi,

 

As I mentioned in the first email I do not have any  issues to login and GET the data. I am getting error when POSTing the data only.In the previous email I sent only POST method.

 

Thanks,

Suneetha

Message 12 of 16
tony.mandatori
in reply to: Anonymous

tony.mandatori
Autodesk
Autodesk

In C#,

 

The code needs to retrieve and reuse the sessionid that is obtained when logging in - here are some snippets (not other libraries are being used here, so the code might not work as is for you: but the methods are standard).

 

var response = client.PostAsJsonAsync("rest/auth/1/login.json", pbody).Result;

if (response.IsSuccessStatusCode)

{

var content = response.Content.ReadAsStringAsync().Result;

dynamic elem = JsonConvert.DeserializeObject(content);

return elem.sessionid;

}

 

Then when sending the request, we need to set the cookie:

 

 

HttpClientHandler handler = new HttpClientHandler()

{

CookieContainer = new CookieContainer()

};

 

handler.CookieContainer.Add(new Uri(url), new Cookie("JSESSIONID", sessionid));

 

using (var client = new HttpClient(handler))

{

client.BaseAddress = new Uri(url);

client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

HttpResponseMessage response =

client.PostAsJsonAsync("api/rest/v1/workspaces/" + wsid + "/items/" + parent + "/boms", tobj).Result;

....

 

 

Note: I didn't write this code, but this is what I typically see.

 

0 Likes

In C#,

 

The code needs to retrieve and reuse the sessionid that is obtained when logging in - here are some snippets (not other libraries are being used here, so the code might not work as is for you: but the methods are standard).

 

var response = client.PostAsJsonAsync("rest/auth/1/login.json", pbody).Result;

if (response.IsSuccessStatusCode)

{

var content = response.Content.ReadAsStringAsync().Result;

dynamic elem = JsonConvert.DeserializeObject(content);

return elem.sessionid;

}

 

Then when sending the request, we need to set the cookie:

 

 

HttpClientHandler handler = new HttpClientHandler()

{

CookieContainer = new CookieContainer()

};

 

handler.CookieContainer.Add(new Uri(url), new Cookie("JSESSIONID", sessionid));

 

using (var client = new HttpClient(handler))

{

client.BaseAddress = new Uri(url);

client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

HttpResponseMessage response =

client.PostAsJsonAsync("api/rest/v1/workspaces/" + wsid + "/items/" + parent + "/boms", tobj).Result;

....

 

 

Note: I didn't write this code, but this is what I typically see.

 

Message 13 of 16
Anonymous
in reply to: tony.mandatori

Anonymous
Not applicable

Hi,

 

Below are my steps. 

I have the login code as below.

After the below step i wrote a class to POST data.

public bool login(string userName, string password)
{
string tenantURIinput = _tenantURI + "rest/auth/1/login.xml";
string payload = String.Format("<authCommand><userID>{0}</userID><password>{1}</password></authCommand>", userName, password);

HttpWebResponse response = post(tenantURIinput, payload);

XmlDocument xmlDoc = new XmlDocument();

using (XmlReader reader = XmlReader.Create(response.GetResponseStream(), new XmlReaderSettings() { CloseInput = true }))
{
xmlDoc.Load(reader);
}

if (xmlDoc.DocumentElement.SelectSingleNode("/userAuthInfo/authStatus/id").InnerText == "200")
{
_authCookie = response.Headers["Set-Cookie"];
_loggedIN = true;
return true;
}
else
{
_authCookie = "";
_loggedIN = false;
return false;
}
}

Also below is my requirement.If you can suggest how to achieve this that would be great helpful for us.

 

We have a share point list and we would like to create a concurrent process to load sharepoint list to PLM workspace.

right now I am planning to create a ssis package to load sharepoint list in to sql server table,and then from sql table to Workspace using C#.net.

But if you have any other solutions please do let me know.

 

Please suggest the best way.

 

Thanks,

Suneetha 

 

 

0 Likes

Hi,

 

Below are my steps. 

I have the login code as below.

After the below step i wrote a class to POST data.

public bool login(string userName, string password)
{
string tenantURIinput = _tenantURI + "rest/auth/1/login.xml";
string payload = String.Format("<authCommand><userID>{0}</userID><password>{1}</password></authCommand>", userName, password);

HttpWebResponse response = post(tenantURIinput, payload);

XmlDocument xmlDoc = new XmlDocument();

using (XmlReader reader = XmlReader.Create(response.GetResponseStream(), new XmlReaderSettings() { CloseInput = true }))
{
xmlDoc.Load(reader);
}

if (xmlDoc.DocumentElement.SelectSingleNode("/userAuthInfo/authStatus/id").InnerText == "200")
{
_authCookie = response.Headers["Set-Cookie"];
_loggedIN = true;
return true;
}
else
{
_authCookie = "";
_loggedIN = false;
return false;
}
}

Also below is my requirement.If you can suggest how to achieve this that would be great helpful for us.

 

We have a share point list and we would like to create a concurrent process to load sharepoint list to PLM workspace.

right now I am planning to create a ssis package to load sharepoint list in to sql server table,and then from sql table to Workspace using C#.net.

But if you have any other solutions please do let me know.

 

Please suggest the best way.

 

Thanks,

Suneetha 

 

 

Message 14 of 16
tony.mandatori
in reply to: Anonymous

tony.mandatori
Autodesk
Autodesk

Thanks for responding.

 

The code you provided above looks a little different.  I think we need to be careful on the format of the headers that are supplied.

 

I see that the code provide is using the following:

request.Headers.Add(HttpRequestHeader.Cookie, _authCookie);

 

So, could you print out _authCookie and ensure that it is formatted properly?  The code that I have looks for an element called sessionid and then builds a string with a prefix of JSESSIONID:

 

Thanks,

0 Likes

Thanks for responding.

 

The code you provided above looks a little different.  I think we need to be careful on the format of the headers that are supplied.

 

I see that the code provide is using the following:

request.Headers.Add(HttpRequestHeader.Cookie, _authCookie);

 

So, could you print out _authCookie and ensure that it is formatted properly?  The code that I have looks for an element called sessionid and then builds a string with a prefix of JSESSIONID:

 

Thanks,

Message 15 of 16
Anonymous
in reply to: tony.mandatori

Anonymous
Not applicable
Accepted solution

Hi,

 

Thanks for your reply and I am able to create items using api.

Below is my code. After successfully logged in I am able to create the item.But If I have the json string like below(redcolor font) I am getting again 500 Internal server error. Can you please send me the format. 

public bool login(string userName, string password)
{
string tenantURIinput = _tenantURI + "rest/auth/1/login.xml";
string payload = String.Format("<authCommand><userID>{0}</userID><password>{1}</password></authCommand>", userName, password);

HttpWebResponse response = post(tenantURIinput, payload);

XmlDocument xmlDoc = new XmlDocument();

using (XmlReader reader = XmlReader.Create(response.GetResponseStream(), new XmlReaderSettings() { CloseInput = true }))
{
xmlDoc.Load(reader);
}

if (xmlDoc.DocumentElement.SelectSingleNode("/userAuthInfo/authStatus/id").InnerText == "200")
{
_authCookie = response.Headers["Set-Cookie"];
_loggedIN = true;
string RequestUri = _tenantURI + "api/rest/v1/workspaces/54/items";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(RequestUri);
httpWebRequest.Headers.Add(HttpRequestHeader.Cookie, _authCookie);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{

string json = @"{
'metaFields':{
'entry': [
{'key':'TYPE','value':'B-Temia'},
{'key':'QA_COMMENTS','value':'Testing by Suneetha'}]
} }";

streamWriter.Write(json.Replace("'","""));
streamWriter.Flush();
streamWriter.Close();
}

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
return true;
}
else
{
_authCookie = "";
_loggedIN = false;
return false;
}
}

 

0 Likes

Hi,

 

Thanks for your reply and I am able to create items using api.

Below is my code. After successfully logged in I am able to create the item.But If I have the json string like below(redcolor font) I am getting again 500 Internal server error. Can you please send me the format. 

public bool login(string userName, string password)
{
string tenantURIinput = _tenantURI + "rest/auth/1/login.xml";
string payload = String.Format("<authCommand><userID>{0}</userID><password>{1}</password></authCommand>", userName, password);

HttpWebResponse response = post(tenantURIinput, payload);

XmlDocument xmlDoc = new XmlDocument();

using (XmlReader reader = XmlReader.Create(response.GetResponseStream(), new XmlReaderSettings() { CloseInput = true }))
{
xmlDoc.Load(reader);
}

if (xmlDoc.DocumentElement.SelectSingleNode("/userAuthInfo/authStatus/id").InnerText == "200")
{
_authCookie = response.Headers["Set-Cookie"];
_loggedIN = true;
string RequestUri = _tenantURI + "api/rest/v1/workspaces/54/items";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(RequestUri);
httpWebRequest.Headers.Add(HttpRequestHeader.Cookie, _authCookie);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{

string json = @"{
'metaFields':{
'entry': [
{'key':'TYPE','value':'B-Temia'},
{'key':'QA_COMMENTS','value':'Testing by Suneetha'}]
} }";

streamWriter.Write(json.Replace("'","""));
streamWriter.Flush();
streamWriter.Close();
}

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
return true;
}
else
{
_authCookie = "";
_loggedIN = false;
return false;
}
}

 

Message 16 of 16
dany.poudrier
in reply to: Anonymous

dany.poudrier
Alumni
Alumni

Hi,

 

You need to use double quotes when writing json, it is the standard.  Single quote is not.

 

From the www.json.org standard: "A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested."

 

So make sure your end results looks like this:

 

{ 
	"metaFields":{ 
		"entry": [ 
				{"key":"TYPE","value":"B-Temia"},
				{"key":"QA_COMMENTS","value":"Testing by Suneetha"}]
	} 
}


Dany Poudrier

PLM Product Manager
0 Likes

Hi,

 

You need to use double quotes when writing json, it is the standard.  Single quote is not.

 

From the www.json.org standard: "A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested."

 

So make sure your end results looks like this:

 

{ 
	"metaFields":{ 
		"entry": [ 
				{"key":"TYPE","value":"B-Temia"},
				{"key":"QA_COMMENTS","value":"Testing by Suneetha"}]
	} 
}


Dany Poudrier

PLM Product Manager

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report