I'm trying to perform a "post" operation in Firebase Database with a GPRS module.
The AT commands of the modem are sent with an Arduino Uno
GPRScommand("AT+CIPSEND", ">", "yy", 10000, 1); /
delay(500);
GPRSboard.print("POST .json?auth=");
GPRSboard.print(FIREBASE_AUTH);
GPRSboard.print(" HTTP/1.1");
GPRSboard.print("\r\n");
GPRSboard.print("Host: ");
GPRSboard.print("XXXXXXXXXXXXXXX-461a8.firebaseio.com");
GPRSboard.print("\r\n");
GPRSboard.print("Content-Type: ");
GPRSboard.print("application/json");
GPRSboard.print("\r\n");
GPRSboard.print("Cache-Control: ");
GPRSboard.print("no-cache");
GPRSboard.print("\r\n");
GPRSboard.print("{\"param1\":\"7\"}");
GPRScommand(end_c, "HTTP/1.1", "yy", 30000, 1);
Return me:
+CIPRCV:384,HTTP/1.1 400 Bad Request
I've tried using Postman. When I write the data I want to publish in the "Body" tab in JSON format, the submission works perfectly:
{
"param1":"7"
}
But when I try to write directly in the "body" of the message in x-www-form-urlencoded format I do not know what to put in "key" or "value". I've tried with:
key=data y value="{\"param1\":\"7\"}"
key=data y value='{\"param1\":\"7\"}'
I always receive the same message: "error": "Invalid data; could not parse JSON object, array, or value."
If I look at the code generated by Postman when I made the request correctly, I see something like this:
POST /.json?auth=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX HTTP/1.1
Host: XXXXXXXXXXXXXXX-461a8.firebaseio.com
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 2f95151e-52e1-28e7-9583-c0a8f50f77d7
{
"param1":"7"
}
I have tried to send this same thing using AT commands to the GPRS module but I get an error that I am sending incorrectly.