cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

POST JSON

PRopars
3-Visitor

POST JSON

Hi,

I try to send a POST command to an API with this code :

 

var json = {
"machinecode": "E5",
"dispatchtypecode": "PANNE",
"description": "Temps de vide trop long > Chambre Droite",
"tradecode": "Maintenance"
};

var url1 = "https://xxx.com/api/1.0/dispatches/open/?auth=abcdefghij&site=50";

var params = {
headers: header /* JSON */,
url: url1 /* STRING */,
content: json /* JSON */
};

// result: JSON
var result = Resources["ContentLoaderFunctions"].PostJSON(params);

 

But I receive this return :

{"headers":"","success":false,"error":"Unexpected error in open. If problem persists contact Support."}

 

Could you help me, please ?

2 REPLIES 2

Welcome to the forums, PRopars!

 

Do you have the variable "headers" set to anything? Does it need to be?

 

We often use the free Postman app to troubleshoot API calls. I would give it a whirl and see if you can post from it. https://www.getpostman.com/downloads/

Hi,

 

Headers is empty.

 

It works fine with this topic :

https://community.ptc.com/t5/ThingWorx-Developers/REST-call-how-to-use-x-www-form-urlencoded-authentication/td-p/501905

 

I think that server no authorize application/json POST

Top Tags