POST request not sending data - fixed


t00n

I've been programming in Android Studio for a short amount of time and have been trying to send JSON to an IIS server in a few different ways (Retrofit2, Volley, HttpClient...) but my IIS APP is not getting it right New rows are not introduced in Mysql BBDD.

This method is from my IIS APP which receives a Json, converts it to Object, then makes a query to my BBDD and brings in new rows.

 public String Post([FromBody] Empleado empleado)
    {}

This method works great as I have tried it from an IIS console application and it works fine

Two examples of what I've done in Android Studio:

Volley:

public class MainActivity extends AppCompatActivity {

TextView textView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    enviarDatos();
}

public void enviarDatos(){
    String url ="http://...myurl";
    textView = (TextView)findViewById(R.id.text);

    try {
        RequestQueue requestQueue = Volley.newRequestQueue(this);
        final org.json.JSONObject jsonBody = new org.json.JSONObject();

        jsonBody.put("idTag",112353);
        jsonBody.put("Longitud","1253");
        jsonBody.put("Latitud","Test");

        JsonObjectRequest request = new JsonObjectRequest
                (Request.Method.POST, url, jsonBody, new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject response) {
                        textView.setText(response.toString());
                    }
                }, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError error) {
                        // TODO Auto-generated method stub
                        textView.setText(error.toString());
                    }
                });

        requestQueue.add(request);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
}

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />

Any help would be appreciated, thanks for your comment, sorry for my bad english

EDIT: Finally it works! Seems like there was some problem with my URL port, so I changed it and it works fine now.

t00n

Finally, it's working! Seems like I had some issues with my URL port, so I swapped it out for another and it works fine now.

Related


POST request not sending data - fixed

t00n I've been programming in Android Studio for a short amount of time and have been trying to send JSON to an IIS server in a few different ways (Retrofit2, Volley, HttpClient...) but my IIS APP is not getting it right New rows are not introduced in Mysql BB

Error sending POST request with data

beginner I'm trying to create a program that will create an account on this site: https://www.kostkuj.cz/register My main problem is that I don't really know how it works, so I've rebuilt one according to my requirements project. I also tried sending a request

Error sending POST request with data

beginner I'm trying to create a program that will create an account on this site: https://www.kostkuj.cz/register My main problem is that I don't really know how it works, so I've rebuilt one according to my requirements project. I also tried sending a request

Error sending POST request with data

beginner I'm trying to create a program that will create an account on this site: https://www.kostkuj.cz/register My main problem is that I don't really know how it works, so I've rebuilt one according to my requirements project. I also tried sending a request

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Error sending data using POST request in Android

Nikolai Stankovic I always get the same error when sending the username and password to the server. I need to send the data as content-type: form-data because the server doesn't respond to any other type. I tested in postman and it's ok, but when I try to send

Ajax request not sending data via POST

grumpy croton I have the following Javascript function http_post = function (url, data, success) { var json_data = JSON.stringify(data); return $.ajax({ type: "POST", url: url, data: json_data, dataType: "json",

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

jQuery Ajax not sending multiple data with post request

I am eating I am trying to send back an array or object using jquery post request. I have multiple inputs with the same name like: $.ajax({ type: "POST", url: "/details", date:{ number:$('input[name="number[]"]').val()

Problem sending data via post request in Python

Phantom Fang I'm trying to enter a start and end date for a decision in 2 input boxes on the Gosport Council website by sending a post request. Whenever I print out the text I received after sending the request, it gives me the information that is displayed on

QNetworkAccessManager not sending data part of POST request

Muldosan Cup When sending POST data from the server, everything looks fine from the Qt application, but the data part of the HTTP part is not sent. In Wireshark, the correct "Content-Length" value is visible in the POST packet, but the size of the entire HTTP

Error sending data using POST request in Android

Nikolai Stankovic I always get the same error when sending the username and password to the server. I need to send the data as content-type: form-data because the server doesn't respond to any other type. I tested in postman and it's ok, but when I try to send

Chrome extension post request not sending data

Dillon First time using the site to ask a question. I'm new to Chrome extensions so I'm sure I'm making some stupid mistakes. I apologize in advance. I'm trying to get the url of the current tab, post it to the url, then receive it and push it to the database.

jQuery Ajax not sending multiple data with post request

I am eating I am trying to send back an array or object using jquery post request. I have multiple inputs with the same name like: $.ajax({ type: "POST", url: "/details", date:{ number:$('input[name="number[]"]').val()

Chrome extension post request not sending data

Dillon First time using the site to ask a question. I'm new to Chrome extensions so I'm sure I'm making some stupid mistakes. I apologize in advance. I'm trying to get the url of the current tab, and post it to a url which is then received and pushed to the da

HTML POST request not sending all data

Akaishi Tian I'm building a very basic search engine for a Library database using Node.js + Express.js. My HTML has a POST form that sends the title or keywords to the application in order to query a book in a MySQL database. Searching by title works great, bu

Angular 7 not sending HTTP Post request data

Tanmay Vij I'm trying to send HTTP Post request to a REST API developed with ExpressJS. I am using the following service file to send requests using Angular's HttpClient: import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/h

Ajax request not sending data via POST

grumpy croton I have the following Javascript function http_post = function (url, data, success) { var json_data = JSON.stringify(data); return $.ajax({ type: "POST", url: url, data: json_data, dataType: "json",

Error sending data using POST request in Android

Nikolai Stankovic I always get the same error when sending the username and password to the server. I need to send the data as content-type: form-data because the server doesn't respond to any other type. I tested in postman and it's ok, but when I try to send

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Objective C post request not sending data

ios development good day. I am trying to send simple post data to the server. This is my code. -(void)makeRequest:(NSString*)stringParameters{ NSError *error; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfigu

Angular 7 not sending HTTP Post request data

Tanmay Vij I'm trying to send HTTP Post request to a REST API developed with ExpressJS. I am using the following service file to send requests using Angular's HttpClient: import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/h