HTTPRequest GET activity not setting correct headers

Hi,

I’m trying consume a REST API with the HTTPRequest activity.
I’m able to authenticate via POST, receive a cookie, and also send these back in the next request together with the ApiKey.

However my GET request needs to set the “Accept: application/hal+json” header to work. This is impossible - I only ever get the application/json response. Is this a bug or does someone have any input?


image

I tried to reply to similar topics in the Advanced section but I’m not allowed.
The same issue is described here:

@TarjeiB,

Can you explain a bit?
Both the headers are acceptable in any request

What is the issue you are getting?

And what type of key you are getting in the post request and how are you passing the authenticated key?

@HareeshMR, the authenticated key (and cookie) aren’t important here, just mentioned as an example that setting cookies work and setting other headers work.

The issue is that to get the correct response from the server, I have to set the header “Accept: application/hal+json”. However, HTTPRequest-activity doesn’t set this correctly, even if other headers work (like “ApiKey” from my example).

It seems to me as if the HTTPRequest-activity has a hardcoded “Accept: application/json” or won’t set the “Accept” header at all.

When I test without the “Accept” header in Postman, I get the same json array response like in UIPath. When I test it with the “Accept: application/hal+json” in Postman, I get the full response that I need also in UIPath.

@TarjeiB,

Are you passing any “Content-Type” request in postman?

I hope you don’t need to change the body format to application/hal+json, make it application/json…

No, not passing any Content-Type, since it’s a GET there is no content. However the reply isn’t application/json, it’s application/hal+json and I need the whole reply (and it’s from a government provider so I can’t change it there).

So no need of passing the body format as application/hal+json as in screenshots attached in the question

Accept you can give whatever you want as we are passing it as string.

Ok, I removed the body format, but it gives the same result.

But when I test this in postman, giving any sort of “Accept: /*” or anything else, I get a json array that is missing data.
When I put “Accept: application/hal+json” I get the full response with all the data that I need. So I have to pass exactly “Accept: application/hal+json” but HTTPRequest doesn’t do this. Is there any way I can make it send this header?

Passing as a header is the only way

Passing in the same way is not giving you the full response, I guess…

make sure your accept type is any

image

can I have the screenshot of postman?

AcceptFormat is set to ANY, and passing as header is also done - that is the bit that’s not working.

So after a bit more digging, it seems that the AcceptFormat overwrites this header with either /*, application/xml or application/json.

I’d like to suggest one of the following for this activity (UiPath.Web.Activities.HttpClient):

  1. AcceptFormat is changed to a text field
  2. Headers are evaluated and added after AcceptFormat (so Headers will overwrite AcceptFormat)
  3. New values are added to AcceptFormat
  4. AcceptFormat is removed

Does anyone have any suggestions on how I can work around this problem for now?

Thanks for all the help so far.