Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Below is the snippet for my test code. The body works fine if it has string key-value pairs. But it fails when numeric values are passed in the body. Also, I cross checked by using Postman that this same snippet containing numeric body works OK. Any suggestion as to what could i try next would be appreciable.
var body = {
"List": {
"pgSize": 1,
"pgNumber": 50,
"State": "On"
}
};
var headers = {
"Authorization": me.AccessToken,
"Content-Type": "application/json",
"Accept-Encoding": "gzip, deflate, br",
"Accept": "application/json",
};
var params = {
proxyScheme: undefined /* STRING */ ,
headers: headers /* JSON */ ,
ignoreSSLErrors: undefined /* BOOLEAN */ ,
useNTLM: undefined /* BOOLEAN */ ,
workstation: undefined /* STRING */ ,
useProxy: undefined /* BOOLEAN */ ,
withCookies: undefined /* BOOLEAN */ ,
proxyHost: undefined /* STRING */ ,
url: url /* STRING */ ,
content: body /* JSON */ ,
timeout: undefined /* NUMBER */ ,
proxyPort: undefined /* INTEGER */ ,
password: undefined /* STRING */ ,
domain: undefined /* STRING */ ,
username: undefined /* STRING */
};
// responseJSON: JSON
var responseJSON = Resources["ContentLoaderFunctions"].PostJSON(params);
Solved! Go to Solution.
Hi @Soura
Thanks for reaching out to us. Can you check below article if this is your requirement:
https://www.ptc.com/en/support/article/CS337595
Try using postText instea of PostJson in last line. Let me know in case of any question.
Regards,
Mohit
Hi @Soura
Thanks for reaching out to us. Can you check below article if this is your requirement:
https://www.ptc.com/en/support/article/CS337595
Try using postText instea of PostJson in last line. Let me know in case of any question.
Regards,
Mohit
Hi @mgoel,
Thanks for your response. I still get the same error(invalid request) with postText() call. Also, note that the body has a nested JSON object as shown below. Any suggestion on how to create the body as shown in your links using this JSON?
var body = {
"List": {
"pgSize": 1,
"pgNumber": 50,
"State": "On"
}
};
I edited the body as below and postText() works ok now.
var body ="{\r\n\"List\": {\r\n\"pgSize\": 1,\r\n\"pgNumber\": 50,\r\n\"State\": \"On\"\r\n}\r\n}";