addHeaderToNextRequest java action not adding header to the post request.

I have an application which needs to POST request to an external service using REST services. The service at https://myService needs authorization header. I used a microflow to call the addHeaderToNextRequest java action but i am still getting the 401 error. the header is supposed to be in the form of id:key I have also tried addCredentialsToNextRequest java action but i am still getting invalid header error
2 answers

Hi Douglas,

Is your service using the basic authentication scheme? In that case you should be able to use addCredentialsToNextRequest. Note that that is not the same as directly using addHeaderToNextRequest, because the basic password scheme encodes the credentials. Can you post both the full exception stacktrace and the documentation concerning authentication of that service? Note that the addCredentials request must be made before each post action call.


Ok, this gets a bit confusing. So you are probably trying to consume ''? It mentions that it serves a post, but with that they mean that they return a blogpost, in the sense of a message on website. So a post like this message.

POST in REST terms however means something entirely different, it is a verb from the HTTP protocol that indicates that you want to submit data to a server. However the usecase you are testing (if I am correct) is to retrieve the (blog)post from the server, and for that you should use the HTTP GET verb. For example if you browse to '' with your webbrowser, the webbrowser will perform a GET request to get the post to you.

So to get this working build an transient object (named BlogPost for example) in your domain model, with the following attributes: "_id", "title", "slug", "content", or simply put, a string attribute for every attribute in the example response.

In your microflow, create a new instance of this BlogPost entity, and pass it as 'stub' parameter to a 'get' java action. Authentication and url should still be the same. After performing the get, all attributes of your newly created object should be filled properly.

That should be all.