Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send list of class objects as a body parameter. #509

Open
fidahussain2356 opened this issue May 25, 2020 · 0 comments
Open

How to send list of class objects as a body parameter. #509

fidahussain2356 opened this issue May 25, 2020 · 0 comments

Comments

@fidahussain2356
Copy link

Below is my code.
AndroidNetworking.post("http://"+ Login.ip+"/api/teachers/test_courses")
.addBodyParameter(added_courses_list)
.setTag("test")
.setPriority(Priority.IMMEDIATE)
.build()
.getAsString(new StringRequestListener() {
@OverRide
public void onResponse(String response) {

                    Log.i("success",response);
                }

                @Override
                public void onError(ANError anError) {

                    Log.i("Error code", String.valueOf(anError.getErrorCode()));
                    Log.i("Error Detail",anError.getErrorDetail());
                    Log.i("Error Body",anError.getErrorBody());
                }
            });

and this is code of web api.

    [HttpPost]
    [Route("test_courses")]

    public HttpResponseMessage test_courses([FromBody] List<model_teacher_add_courses> obj)
    {
        HttpResponseMessage message = null;
        if (obj == null)
        {
            message = Request.CreateResponse("Its null.");
        }
        else
        {
            model_teacher_add_courses m = new model_teacher_add_courses();
           
            message = Request.CreateResponse(obj);
        }

return message;
}

when i run this code "its null" is returned. i think list is not reaching to web api.
Kindly help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant