Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hi all,
I am trying to generate a bearer token from azure on Thingworx (9.3.2) using getJSON function, but I am facing "Message :: Invalid Content-Type: text/html - See Script Error Log for more details" this issue. When I tried it from the postman, it was working fine! I am using the below URL and headers in my code
var url = "https://login.microsoftonline.com/XXXXXXXXXXXxX/oauth2/token";
var headers = {
"Accept": "text/html",
"Content-Type": "text/html",
"grant_type": "client_credentials",
"client_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
"client_secret" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"resource" : "https://servicebus.azure.net"
};
Thank you!
Solved! Go to Solution.
I have found the solution for my issue, I am able to generate the bearer token in thingworx using the PostText method, I gave the content in a string and content type as "application/x-www-form-urlencoded".
Thank you for your help @PaiChung !!
Thingworx won't do text/html try text/xml instead
Hi @PaiChung,
Thank you for the response. While creating the token from the postman, I wrote the "grant_type": "client_credentials",
"client_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX", "client_secret" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "resource" : "https://servicebus.azure.net" under form-data -> body of postman. How to write this body part in Thingworx?
Within the contentloader functions I believe the 'body' is called 'content'
So you would have to create that content similar to the body.
Hi @PaiChung, I am using the PostMultipart function, and in the "partsToSend" I have updated the client id, secret id in infotable, and in the content type I am using "multipart/form-data; charset=UTF-8", but I am getting Invalid-Request for this!!
Can you please help me with this!!
I've never used this service, so I am unsure what might need to be changed.
I have found the solution for my issue, I am able to generate the bearer token in thingworx using the PostText method, I gave the content in a string and content type as "application/x-www-form-urlencoded".
Thank you for your help @PaiChung !!