401 Authentication error REST integration

2
Hi all, I'm trying to get an connection going with a dev instance of ServiceNow.  I followed the documentation of ServiceNow to see what is needed to get their OAuth access token before submitting this to get the data I really need. Since their documentation starts with trying it in Postman I started here as well. So far so good. Everything works fine with both getting the OAuth token as the data. When I try this to get this going in Mendix 7.22.2 using the Call REST service microflow action I enter the same Body and Header information.  However when using this I get a 401 Authentication error: REST Consume: Request content for POST request to https://dev58829.service-now.com/oauth_token.do HTTP/1.1 INFO content-type: application/x-www-form-urlencoded INFO {"grant_type":"password","client_id":"784f95813c303300cde118edbd5d1169","client_secret":"Mendix10","username":"admin","password":"Mendix10"} 13:31:54APPTRACEREST Consume: Response content for POST request to https://dev58829.service-now.com/oauth_token.do 13:31:54APPINFOHTTP/1.1 401 Unauthorized …. 13:31:54APPINFOConnection: close 13:31:54APPINFO{"error_description":"access_denied","error":"server_error"}  So I went to the forum to different questions about REST and curl/postman (e.g. https://forum.mendix.com/link/questions/88266) and tried out different scenario's. Different encodings (html, url, base64, unencoded) Extra headers after comparing the header output in RequestBin Export Mapping vs Custom request template in the Request None of these options made a difference and didn't solve the 401 Authentication Error What I noticed in Reuqestbin was the format of the Body when viewing it in raw instead of structured. Postman: grant_type=password&client_id=784f95813c303300cde118edbd5d1169&client_secret=Mendix10&username=admin&password=Mendix10 Mendix: {"grant_type":"password","client_id":"784f95813c303300cde118edbd5d1169","client_secret":"Mendix10","username":"admin","password":"Mendix10"}   Could this make a difference? And is this leading to the Authentication error?  Hope anyone can share her/his experience with solving these kind of issues. Thanks!   ADDED: The body of the Request is an export mapping with the following details: I've filled each attribute of the NewRequestSnow with the value previously given (and have tried it for unencoded, urlencoded, htmlencoded and base64encoded).  
asked
1 answers
2

The problem is that in postman you use post parameters where in Mendix you build a JSON request body.

Can you show us how you build your request in your REST Call?

 

answered