Need some help to get REST (POST) service working?

1
I'm struggeling getting a very simple REST call working. It's resulting in an '401 access denied'. Exactly similar REST post action over Postman, runs without any problems.  Let Mendix talk to an local "SOAP mocking service", is showing the right result as well. --> only tested on HTTP   Can someone bring some help? Remarks: I'm contacting the MS Cognitive services API, which is HTTPS --> does this require a change in Mendix? Please checkout attached video : https://s3-eu-west-1.amazonaws.com/cardstestpublic/Mendix_callREST.mp4 Is there a way to DEBUG the Mendix internal web calls and see the raw payload? --> changed the debug level to 'debug', still same stacktrace output.  
asked
5 answers
4

Hi everyone,

Thanks for the great feedback and potential solution directions. The problem is solved now!

  • Due to my current status as Mendix newbie, I learned today how to get eyes on the payloads. Especially the advanced logging was very helpful.
  • It didn't digest the API key, unless it was delivered in the header of the call.
{"error":{"code":"Unspecified","message":"Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key."}}
  • After comparing the request message from Mendix with my Postman payload, I found out the problem was caused by some addtional apostrophes I added around the key name
  • After removing them the REST call works fine.

 

Thanks for the quick responses.

ps. I can everyone advise to play around with the MS Cognitive services, especially the computer vision ones are quite cool for images comparison and analytics.

 

 

 

answered
1

401 usually means your call failed security checks.

Are you using the correct credentials in your request (i.e. username and password)? 

 

Edit: Looking at some examples of azure cognitive services I can see a subscription key being used, perhaps this is what you need

Also specifying what your call looks like and which endpoint your calling would be really useful for us to be able to tell exactly what you're missing.

answered
1

You'll want to change the debug level to Trace in this case. You'll be able to see the payload to check the exact request and response. It'll be easier to compare.

Be sure to put the correct node on trace though. There's Rest Consume, Rest Publish and Webservices (soap)

In this case, are your credentials correct? seeing as you're getting a 401.

answered
1

Hi Wim,

- Set the Rest Consume log level to 'Trace', this gives you the request/response payload.

- Pay close attention to the authentication headers and custom HTTP headers. For example: Content-Type (should be application/json) or tokens.

- If the Location in the REST-post request is set, Mendix is able to handle HTTPS.

- Do you use a JSON mapping or a custom request template? In the latter case using the correct syntax is very important.

answered
0

Using export mapping seems to work. The custom request template is poorly documented and it does not tell how to fix the format.

answered