Skip to main content
Jun 16, 2022 11:46 AM UTC
Solved

Facing invalid text/html error while using getjson

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!

Jun 24, 2022 4:25 AM UTC

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 !!

7 replies

Jun 17, 2022 5:36 PM UTC

Thingworx won't do text/html try text/xml instead

 

Jun 20, 2022 12:28 PM UTC

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?

 

 

Jun 21, 2022 2:43 PM UTC

Within the contentloader functions I believe the 'body' is called 'content'

So you would have to create that content similar to the body.