I’ve also tried using the system.net.httpPost function and that returned the same error too.
I used the urlencode function on the “body” parameter by referring to this post here, but that also threw the same error. Any help is much appreciated.
Yes, and I think I am doing it right. This is what they’re expecting Refreshing access & refresh tokens. I also forgot to mention that I am having no issues refreshing the token using postman.
Here are the headers:
My bad, thought I only had to encode the dictionary. Looks like urlencode only works with dictionaries because it was returning TypeError: not a valid non-string sequence or mapping object when I was using it with a string. Did some research and it looks like I have to use urllib.quote or urllib.quote_plus with a string and non of them worked. Both returned {'error': u'unsupported_grant_type'}
Hmm, well I just looked at the docs for urlencode, and you can pass it a dictionary, which I didn’t know.
I’m assuming you can’t access the URL via plain HTTP, so you might need to get some kind of local HTTP mitm/dev proxy set up that will let you see what the difference between what you’re sending via Postman and Ignition is.
Just figured it out! I clicked on the code snippet icon </> in PostMan and selected the ‘Python - http.client’ option from the dropdown. I saw that the code was importing the encode module from a library called codecs. So I tried it out and system.net.httpClient().post is returning the expected response now. My script became like this: