-
Problem report
-
Resolution: Unresolved
-
Trivial
-
None
-
4.4.7
I am developing webhook integration with third party application that requires authorization via tokens in headers.
When I use this code:
json = .... ... req = new CurlHttpRequest(); req.AddHeader('Content-Type', 'application/json'); req.AddHeader('Auth-Token', params.user_token); req.AddHeader('User-Id', params.user_id); ... resp = req.Post(url, JSON.stringify(json)); ...
I receive status code 401 with message "You must be logged in to do this." from third party application.
But when I use this code
json = .... ... req.AddHeader('Content-Type: application/json'); req.AddHeader('Auth-Token: ' + params.user_token); req.AddHeader('User-Id: ' + params.user_id); ... resp = req.Post(url, JSON.stringify(json)); ...
everything works fine and I receive code 200.
From this I concluded that setting the headers does not work correctly in the first code example.
According to this documentation, I pass two parameters to AddHeader function, but this not working as expected. But code examples (in the documentation) use string concatenation instead of passing two parameters and this working great.
Where is the mistake? In the documentation or code examples?