Http post server done 302

Hello,

I am trying to send data from a 4G device to ubidots but it displays a response from a 302 server so it does not show me the data sent correctly.

I am making the http post with the following URL: industrial.ubidots.com/api/v1.6/devices/deviceID/?token&_method=post&value=22

How could I solve it?

Thank you

Hello @allanch22,

There are a few key points that you should keep in mind and change:

  1. Instead of industrial.ubidots.com you must use industrial.api.ubidots.com. This is the correct domain for the API ingestion server.
  2. After the “token” query parameter, you must provide the actual account TOKEN.
  3. I’m not sure what you mean with deviceID, but in that specific position of the path, you need to enter a DEVICE_LABEL. For your reference, Device IDs and Labels are not the same: while both account for a unique identifier for a Device within Ubidots, the first is assigned by Ubidots and the second is of your choice.
  4. At last, you need to provide a VARIABLE_LABEL for each variable you’d like to send. I’d recommend not calling it “value” but something more saying, like for example, “temperature” or “humidity”. This is how the variable will be labelled within the DEVICE_LABEL Device.
  5. The HTTP method to send data this way is a GET

With this recommendations in mind, here’s how your URL should look like:

STRUCTURE
GET => http://industrial.api.ubidots.com/api/v1.6/devices/DEVICE_LABEL/?token=TOKEN&_method=post&VARIABLE_LABEL1=22&VARIABLE_LABEL2=33&······&VARIABLE_LABEL_N=55

REPLACED
GET => http://industrial.api.ubidots.com/api/v1.6/devices/demo/?token=BBFF-SFerFERFEWFE244fFW&_method=post&temperature=22&humidity=33&pressure=55

Furthermore, while this is supported by Ubidots, it best to actually send data using a POST request. You can find an explanation and examples about it in the HTTP section of Ubidots’ Hardware Docs.

Last but not least, can you point me and the other users that might read this thread, where did you find it that method to posting data, that is, using the _method=post query parameter?

–David

I already did what you said and now display this

image

image

The strange thing is that I paste that url in the search engine and it updates the data in the dashboard

I already resolved it

Thank you very much

Hello @allanch22

That makes sense since the browser makes a GET request to the provider URL. In this case, that URL sends data to your account.

Furthermore, do you mind sharing what was the issue for other users in the future encountering the same problem?

Also, can you point me and the other users that might read this thread, where did you find it that method to posting data, that is, using the _method=post query parameter?
BTW, glad to know you worked it out.

Nothing else changes in my code the method of post by get.

I found this method to publish the data in this thread