Esp8266MOD+htpp// url post data on server

Hello, I want to send data on my sever . so first i sharing my sever information below.
New Ticket:

URL: http://jbcweighingscale.com/ admin_ws/api.php

METHOD: POST

PARAM:

tag : addData

data: charges="200"&charges_2="NA"& first_weight_time="23/08/2020 04:29 PM"&gross="5000.000"&item=" DIODE"&net="2000.000"&party_ address="AJMER"&party_name=" AMAN1"&rstNo=(blank-in-case- of-new-ticket)&second_weight_ time="23/08/2020 04:29 PM"&tare="3000.000"&vehicle_ type="TRUCK"&vehile_no=" RJ01CC5698"&weighbridgeId= 17177&localRstNo="1"

RESPONSE: 1632566440686
Possible Error in Response:

  1. WEIGHBRIDGE_ID_MISSING

  2. EMPTY_BODY : When no data received at server

  3. RST_NO_MISSING


#include <ArduinoHttpClient.h>
#include <ESP8266WiFi.h>;
#include <WiFiClient.h>;
#define ss "vivo"
#define paa "12345678"
char ssid[] =ss; //Your Network SSID
char pass[] = paa; //Your Network Password
char  charges[] ="200";
char  charges_2[] ="NA";
char  first_weight_time[] ="23/08/2020 04:29 PM";
char  gross[] ="5000.000";
char  item[] =" DIODE";
char  net[] ="2000.000";
char  party_address[] ="AJMER";
char  party_name[] =" AMAN1";
char  rstNo[] ="blank-in-case-of-new-ticket";
char  second_weight_time[] ="23/08/2020 04:29 PM";
char  tare[] ="3000.000";
char  vehicle_type[] ="TRUCK";
char  vehile_no[] =" RJ01CC5698";
char  weighbridgeId[] = "17177";
char  localRstNo[] ="1";




const char serverAddress[] = "http://jbcweighingscale.com";  // server address
int port = 80;

WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;

void setup() {
  Serial.begin(9600);
  WiFi.begin(ssid, pass);
  while(WiFi.status() !=WL_CONNECTED)
 {
  
 Serial.print("Attempting to connect to Network named: ");
 Serial.println(ssid);                   
 delay(500);
 }
 
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.println("Connected to WiFi network with IP Address: ");
  Serial.print("IP Address: ");
  Serial.println(ip);
}




void loop() {
  // assemble the path for the POST message:
  String dweetName = "PARAM";
  String path = "/admin_ws/api.php" + dweetName;
  String contentType = "application/json";

  // assemble the body of the POST message:
  
  String postData = "{\"data\":\""; 
  
  postData +=  charges,charges_2,first_weight_time,gross,item,net,party_address,party_name,rstNo,second_weight_time,tare,vehicle_type,vehile_no,weighbridgeId,localRstNo;
  postData += "\"}";
  Serial.println("making POST request");

  // send the POST request
  client.post(path, contentType, postData);

  // read the status code and body of the response
  int statusCode = client.responseStatusCode();
  String response = client.responseBody();

  Serial.print("Status code: ");
  Serial.println(statusCode);
  Serial.print("Response: ");
  Serial.println(response);

  Serial.println("Wait ten seconds\n");
  delay(10000);
}

on running this i got this output:

making POST request
Status code: -2
Response:

status coade -2 mean???
and what changes shoud i do for send data properly

If i add these together

  String dweetName = "PARAM";
  String path = "/admin_ws/api.php" + dweetName;

path will look like this

 "/admin_ws/api.phpPARAM"

There probably needs to be a separator.
the same here :

postData +=  charges,charges_2,first_weight_time,gross,item,net,party_address,party_name,rstNo,second_weight_time,tare,vehicle_type,vehile_no,weighbridgeId,localRstNo;

So you are not sending the data in a way that it is expected.

thanks for response,
pleas suggest how to write in right manner.

please help

please help

Where is your effort ?

What is it supposed to look like ?

Here it is supposed to look like this

data: charges="200"&charges_2="NA"& first_weight_time="23/08/2020 04:29 PM"&gross="5000.000"&item=" DIODE"&net="2000.000"&party_ address="AJMER"&party_name=" AMAN1"&rstNo=(blank-in-case- of-new-ticket)&second_weight_ time="23/08/2020 04:29 PM"&tare="3000.000"&vehicle_ type="TRUCK"&vehile_no=" RJ01CC5698"&weighbridgeId= 17177&localRstNo="1"

so how are you going to make it look like this ?

sir /i am doing it first time so , please explain what changes should i do in my program,
and how to pic use full information form
URL: http://jbcweighingscale.com/ admin_ws/api.php

METHOD: POST

PARAM:

tag : addData

data: charges="200"&charges_2="NA"& first_weight_time="23/08/2020 04:29 PM"&gross="5000.000"&item=" DIODE"&net="2000.000"&party_ address="AJMER"&party_name=" AMAN1"&rstNo=(blank-in-case- of-new-ticket)&second_weight_ time="23/08/2020 04:29 PM"&tare="3000.000"&vehicle_ type="TRUCK"&vehile_no=" RJ01CC5698"&weighbridgeId= 17177&localRstNo="1"
this data

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.