Hi,

I am currently tring to connect XDK directly to Bosch IoT Things service.

After going through the documents and example code, I know how to post data through plain http service by using Msg_prependPartFactory(), but, is it possible to customize http header? because Things service requires some extra information to be added, e.g. api token.

BTW, could you provide more details about struct Msg_T ?

Thanks.

Shaodong

 

 

+3 (3 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
7/14/16 7:27 AM as a reply to Shaodong Ying.

Hi Shaodong,

the http header can’t be customized, because it is automatically generated by the serval stack.
Note that the serval stack transfers data with chunked transfer encoding.

The xdk development team is currently improving the whole documentation.
I’m not allowed to provide more details about the struct Msg_T, but I will add this to our improvement list.

Kind regards,
Manuel

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
8/17/16 7:05 AM as a reply to Manuel Cerny.

Hi Manuel, 

I found there's a method in serval_msg.h, 

  void Msg_setAuthorizationTokenCustom(Msg_T *msg_ptr, void* custom);

Could you give more information that how it works? Can I use it to add some custom http header infomation? e.g. user-define-token: 229938ea3b6d4c1da8a19c3a7f58766d

Thanks. 

 

Shaodong

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
8/17/16 2:06 PM as a reply to Shaodong Ying.

Hello Shaodong,

I’m not quite sure, if it is possible to set a http authentication token like this.
But I contacted the responsible developer and will come back to you, as soon as I know more.

Kind regards,
Manuel

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
8/24/16 1:45 AM as a reply to Manuel Cerny.

Hi Manuel, 

 

Could you share a bit more about how to use this function as it is designed for? 

    void Msg_setAuthorizationTokenCustom(Msg_T *msg_ptr, void* custom);

 

BTW, is there any changes on HTTP APIs which might help on this situation in the latest XDK-Workbench-1.6.0?

 

Thanks.

Shaodong

 

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
8/24/16 9:41 AM as a reply to Shaodong Ying.

Hello Shaodong,

I got some information of the developer: to customize the http header, you need to adjust the template into the serval stack.

As far as I know there were no changes in version 1.6 related to this issue

with the function Msg_setAuthorizationTokenCustom() you can attatch authorization information to the message.
To be exact, an authorisation for a specific user can be added to the message. Currently I have no example code but I requested a snipped for you.

Kind regards,
Manuel

+1 (1 Vote)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
8/29/16 6:00 AM as a reply to Manuel Cerny.

Hi everyone,

we were trying the exact same thing here: To connect the XDK to Bosch-IoT-Things via REST API. The problem we came across was that the XDK doesn't support https but that is the only way to communicate with the Cloud. At least for now, or so the developers said. So we added another gateway device in order to connect to things. Can anyone on XDK side confirm this?

Felix

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
8/29/16 6:41 AM as a reply to Felix Gandha Salentin.

Hi Felix, 

 

You can use HTTP for REST API as well, I have tested on Things service.

The headache for me is the customized HTTP header which is required by Things service. 

Gateway is absolutely a workaround here, and workable for some use cases, but it is kind of redundent if considering XDK has wifi module integrated already. Is it? 

Hope XDK team could give some suggestion or any plan for it? 

 

Shaodong

 

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
8/29/16 9:31 AM as a reply to Shaodong Ying.

Hello Felix and Shaodong,

https is currently in developing state and will be released as soon as it is stable.

As Shaodong already mentioned, it is kind of redundant to push the data to a gateway.
But for now, I assume a gateway is a good workaround. You have several possibilities to push the data to the gateway device and post the data to any cloud you like. Additionally I would recommend to use a light protocol to push the data to the gateway device.

Kind reagards,
Manuel

+1 (1 Vote)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
3/29/17 2:39 PM as a reply to Manuel Cerny.

Hi Manuel,

we do have currently the same problem, we try to insert an authorization property to the http header. Are there any update how this can be done?

regards,

Stefan

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
3/29/17 9:34 PM as a reply to Stefan Kraus.

Hello Stefan,

the current state is still that you can customize the http header on your own by altering the template in the serval stack.

unfortunately I got no code snipped, but I will kick off the process again.

I really apologize the inconvenience.

Kind regards,
Franjo

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
5/4/18 4:57 AM as a reply to Franjo Stjepandic.

Hello there. I am currently working to use the xdk to send data over to thingspeak. Upon trying out the HttpExampleClient template, only the GET request works, and when I comment the GET request task out, leaving only the POST request, I get this error:

INFO | XDK DEVICE 1: asserted at Filename 3rd-party/FreeRTOS/Source/tasks.c , line no  4148 

May I know what I can do to send a POST request? This is aimed at the default "postman-echo.com/post" url.

I would also like to know where I can input my thingspeak API key in the http request.

Thank you!

0 (0 Votes)
RE: How to set http header? (e.g. api token for Bosch IoT Things)
Answer
5/4/18 11:42 AM as a reply to Kyle Ledesma.
Hello Kyle,

the error message refers to an assert during the function xTaskNotifyGive() , which is called with httpGetTaskHandle as its input. Since you probably removed the initialization of that task, the handle keeps the value NULL , thus leading to the assert.

I recommend to remove line 347 of the original code.

This is the call
 
xTaskNotifyGive(httpGetTaskHandle);

within the function httpGetResponseCallback() .

As for the API key, I assume that you insert it as a Header.

For this, you can use the custom header macro POST_REQUEST_CUSTOM_HEADER_0 on line 105 of HttpExampleClient.h . Keep in mind that the field-name X-AuthToken may have to be changed as well.

For more complex logic in regards to custom headers, you can directly modify the function httpPostCustomHeaderSerializer() in HttpExampleClient.c

Lastly, you said that upon trying out the HttpExampleClient template, only the GET request works . Does that mean that the POST request does not work at all, even without making modifications to the example?

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Alex
0 (0 Votes)