REST API PUT Method Error

Hello people, i have a problem with connecting to an external server via a rest api connector. I tried to use the http put method to update data in the database, but i get the following error: Caused by: com.mendix.modules.microflowengine.MicroflowException: 307: Temporary Redirect     at Material.UpdateMaterial (CallRest : 'Call REST (PUT)') Can somebody help me with this? Thanks in advance! Best regards, Max
2 answers

In you do a GET or HEAD request and the server returns 307 you will get a response from the new location and there will be no error. For other verbs (such as PUT) you get an error, for safety reasons: by default the app does not redirect your (possibliy sensitive) input to other servers like that.

There are two possible solutions:

  • You could use the new URL and PUT there. You do this when the new URL will be available all the time.
  • You could add an error handler to the Call REST activity, and inspect $latestHttpResponse. If the StatusCode is 307, retrieve the Location header and repeat the Call REST activity to that location.

It looks like the external server is telling Mendix to use an alternative URL via a 307 redirect, but Mendix doesn’t know how to handle this.

One solution could be to turn on the REST Consume LogNode up to TRACE and see what the full response is from the server. It should give you an alternative URL to use, so try substituting this URL for the one you are using currently. This should only really be used as a temporary fix, but it may help in the short term.