makeWebRequest with empty response

I am developing an IoT (Internet of Things) application where the 'thing' is a Garmin Watch.
I am using a REST API (POST) provided by IBM Bluemix to send the information to the IoT dashboard. The problem is that this API call returns no data at all. It's just an event.

When calling the REST service using:


Comm.makeWebRequest("http://<Iot",
{"payload" => hr},
{
"Content-Type" => Comm.REQUEST_CONTENT_TYPE_JSON,
:headers => {
"Accept" => "application/json"
},
:method => Comm.HTTP_REQUEST_METHOD_POST
},
method(:onReceive));
}

I receive in my callback method an UnknowError (0). I have created a dummy service in Java and I have been able to reproduce the problem. When returning just the 200 return code (no output data), I get the UnknownError. I have writen something to the output stream in the server side, then everything goes fine in the Connect IQ simulator: the 200 return code arrives with the contents.

IMHO, the makeWebRequest should accept empty responses. Any ideas?

Thanks in advance.
  • The makeWebRequest() function currently expects that the server will send a message body with every response. That response body currently has to be formatted as JSON/GPX/FIT.

    The workaround at this time is to write a service that doesn't send an empty response. This may mean that you need to add a service that you control between the actual service and your application.

    Travis
  • calle puebla

    The makeWebRequest() function currently expects that the server will send a message body with every response. That response body currently has to be formatted as JSON/GPX/FIT.

    The workaround at this time is to write a service that doesn't send an empty response. This may mean that you need to add a service that you control between the actual service and your application.

    Travis


    Hi Travis,

    thanks for your reply. Yes, that is the 'obvious' solution. But it introduces a degree of complexity because you need a server hosting that servlet. On the other hand, it gives you a degree of freedom by letting you customize your request.

    My suggestion would be adding a HTTP_RESPONSE_CONTENT_TYPE_EMPTY=5 in a newer release of the API.