Authorisation headers through Plugin_HTTP_Request

Recommended Posts

.I don't have prior experience with C++, so this is a learning experience, using Julia as a reference. I'm attempting to make a POST request to my API

ftRequest_t* r = Plugin_HTTP_Request(url, "POST", (byte*)data, stringlen, "Authorization:Bearer TOKEN; Content-Type: application/json\r\n");

When I make the request as per the above, my token isn't passed, and the request gets redirected to a login page, as would be expected without a token. However, if I remove the content-type header;

ftRequest_t* r = Plugin_HTTP_Request(url, "POST", (byte*)data, stringlen, "Authorization:Bearer TOKEN\r\n");  

This will successfully pass the token header.


Could someone point me in the direction of where I may be going wrong with passing multiple headers through this?



Share this post

Link to post
Share on other sites


this is where the string for the headers is assembled.

what you're looking for is probably the following. ";" does not create a new header entry, it's just part of the string value for the last key in the header.

"Authorization:Bearer TOKEN\r\nContent-Type: application/json\r\n"


Share this post

Link to post
Share on other sites

Amazing, that worked!  Thank you.

Now just to figure out why I can see my json through Printf, but it's hitting the end as null.  :) 


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.