I need to send some data from an arduino to an rest based web application.
To test I have created an django based web application on heroku
Now when I trying to send the data from arduino using GSM AT commands it's showing below error
HTTP/1.1 505 HTTP Version Not Supported
Connection: close
Server: Cowboy
Below is my code in arduino
const char HTTP_HEADER_POST[ ] = "POST /api/sprints HTTP/1.1\r\nHost: obttracker.herokuapp.com\r\nContent-Length: 54\r\n\r\nUser-Agent: obttracker\r\nConnection: keep-alive\r\nContent-Type: application/x-wwww-form-urlencoded\r\nAuthorization: Basic ZGVtbzpkZW1v\r\n\r\n"; //HTTP header line before length
const char HTTP_BODY_POST[] = "end=2015-05-19&name=TESTING&point=POINT%2834.2+45.3%29";
int tmp_post_len = strlen(HTTP_HEADER_POST);
//sending header packet to remote host
gsm_port.print("AT+QISEND=");
gsm_port.print(tmp_post_len);
gsm_port.print("\r");
delay(500);
gsm_get_reply();
//sending header
gsm_port.print(HTTP_HEADER_POST);
delay(500);
gsm_get_reply();
//validate header delivery
gsm_validate_tcp();
// send the body data
int body_len = strlen(HTTP_BODY_POST);
gsm_port.print("AT+QISEND=");
gsm_port.print(body_len);
gsm_port.print("\r");
delay(500);
gsm_get_reply();
gsm_port.print(HTTP_BODY_POST);
delay(500);
gsm_get_reply();
//validate previous transmission
gsm_validate_tcp();
parse_receive_reply();
I have tested the web app by send through my linux system using python requests, and it's working below are the details
$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> import requests
>>> import pprint
>>> today = datetime.date.today()
>>> data = {'name': 'TESTSTING', 'end': today, 'point': 'POINT(56.3 33.3)'}
>>> resp = requests.get('http://obttracker.herokuapp.com/api')
>>> resp.status_code
200
>>> api = resp.json()
>>> pprint.pprint(api)
{u'sprints': u'http://obttracker.herokuapp.com/api/sprints'}
>>> resp = requests.post(api['sprints'], data=data, auth=('demo', 'demo'))
>>> resp.status_code
201
>>> sprint = resp.json()
>>> pprint.pprint(sprint)
{u'end': u'2015-04-24',
u'id': 3,
u'links': {u'self': u'http://obttracker.herokuapp.com/api/sprints/3'},
u'name': u'TESTSTING',
u'point': {u'coordinates': [56.3, 33.3], u'type': u'Point'}}
>>>
Request to please provide me suggestion or help to resolve this issue