WIZnet Developer Forum

How to send HTTP request

Hello,

I’m facing problem in sending HTTP request. I’m trying to send to the ubidots server by creating my own variable but while sending every time getting response as "400 BAD Request"
for your reference Here I’m placing the http post request for which I want to create a variable.

<0x1b>S0 curl -i–header “Accept: application/json; indent=4” --header “Content-Type: application/json”–header “X-Auth-Token: ZFJSStMA07BL87bNQtG8IXSPw06y330OIw9ZgUz6xSM3EVxJmdZiHCZ605Dh”-X POST -d ‘{“value”:24}’ things.ubidots.com/api/v1.6/vari … e13/values<0x1b>E

The response is as follows

HTTP/1.1 400 Bad Request
Server: nginx
Date: Mon, 04 Jan 2016 10:43:16 GMT
Content-Type: text/html
Content-Length: 166
Connection: close

400 Bad Request

400 Bad Request


nginx

Could anyone help me how to send the http request successfully.

Thank you

Hi

WizFi210 is based on a TCP layer(as known as Transport layer in TCP/IP layer) connection device. so, WizFi210 is the object in charge of performing the actual connection to the other “TCP layer” device, as well as writing requests and reading responses.

But, “CURL” that you used command is a command line tool using URL syntax(Application Layer in TCP/IP layer)

So, You have to change the request CURL syntax to TCP stream syntax like below.

[quote]
<0x1b>S0
POST /api/v1.6/variables/5689f91b76254265137e8e13/values HTTP/1.1
Content-Type: application/json
Content-Length: 13
X-Auth-Token: ZFJSStMA07BL87bNQtG8IXSPw06y330OIw9ZgUz6xSM3EVxJmdZiHCZ605Dh
Host: things.ubidots.com

{“value”: 24}

<0x1b>E[/quote]

Please copy below text and send to server

  • <0x0d>,<0x0a> are hexadecimal(CR, LF)

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.