Http request - access response headers

(Anders Eidergard) #1

I have an api I’m POSTing to in order to create a session.

It takes some inputs in the request header and responds with a session token in the response header.
Everything fine so far and I’m using the http request module.

My question is - how do I get my hands on the response header?

I need to use it later in the flow when I’ve had more interactions with the user and gathered some info from them.

Thanks in advance
/Anders

(Karen Barker) #2

Hi Anders,

If you take a look at your interaction logs for the webhook anything that you can use will be shown on the Outputs tab for the action. If the headers are shown here then you should be able to use Data Outputs in order to access these. Unfortunately if they aren’t shown then there will be no way to get this information I’m afraid. :worried:

(Anders Eidergard) #3

Thanks Karen,

I can only see the message body in the Outputs tab so I guess I’m out of luck on that approach.
Too bad since it’s really quite simple.

Would it be possible to use JS and a Code component?
Good to know before if it’s worth spending any time on.

/Anders

#4

hi @Anders_Eidergard,

your api approach is not standard, you shouldn’t use headers to send and received data but body.
You could read the webhook guide

(Anders Eidergard) #5

Maybe it isn’t standard but it’s the way it’s set up at the moment.

I’m by no means an expert but from what I can find online it seems a fairly common approach to have auth-tokens and such be in the headers. It’s not really part of the transported data so it makes sense to me.

Anyways - the question is still if I can get at the response header.

The http-module didn’t work, but maybe the Code-module does?

(Karen Barker) #6

Hi Anders,

Unfortunately I’m not actually sure if you can use the code service to handle the request and if this would return the response headers for you. You can definitely do HTTP requests through the code service, I’m just not sure whether you’d get the data back in the response headers here. We don’t support any custom code, so I’m afraid this would need you to give it a go and see. :disappointed:

#7

Hi @Anders_Eidergard,

when you use token you must set it in header auth, of course, to authenticate your call.
When you request token your question and answer from api are json in body (usually response contain token and expire_at).
However if your auth api uses header to get token to client, you should create a new endpoint to get token to client in body, so you can call it from flowxo webhook action.

(Anders Eidergard) #8

I’ve solved it without the bot for now.

We’ll put the token in the body at a later point in time.

Thanks a lot for the help so far.
As always quite useful conversations.

1 Like