0
votes

Try to use the HTTP Messaging API for Watson IoT. https://docs.internetofthings.ibmcloud.com/apis/swagger/v0002/http-messaging.html

I have one application that should POST Mqtt msg from a device. Have generated API key in Watson iot and put it in the POST header e.g:

username: a-XYXYX-bvbcxgmz6d

password: XYXYX+6QY6OKw*J

Content-Type: application/json

I then send this POST to changed my real orgId in this post: http://orgId.messaging.internetofthings.ibmcloud.com:1883/api/v0002/application/types/ecu/devices/ecu1/events/test

But I keep ending up in server response 403 Not allowed.

I use a HTTP REST Chrome application that I have successfully used before. Have run out of ideas so pleas help!

2

2 Answers

1
votes

Hi found out why it didn't work for me.

I have forgotten to generate a Base64 Key to add to the Authorization: Basic headers. I just put username and password as variables in the headers.

I think it was more clear how to do it in the cloudant doc: https://console.ng.bluemix.net/docs/services/Cloudant/api/authentication.html#basic-authentication then in the Watson IoT platform doc.

But thanks for you help!

0
votes

It looks good and the POST works for me. I assume you have double checked device type/device id - that they actually exist in the platform. Perhaps the event itself has something invalid in it messing it up. This is what I send:

  POST /api/v0002/application/types/myType/devices/myDevice/events/test 

    HTTP/1.1 Host: myOrg.messaging.internetofthings.ibmcloud.com:1883 

    Authorization: Basic myAPIKeys 

    Content-Type: application/json

Body is:

{"temp":85}