Is it possible to POST a package of json objects?

Tomaz Mazej

so I am building an applications that has to POST a json array with some information and also json object with user credentials which are going to be used for identification. Is is possible to POST some kind of package that contains json object array + object with user credentials? I am using Retrofit2.

So beside this Array list I would like to send Credentials with one POST request.

public interface JsonPlaceHolderApi {

    @POST("hws/hibisWsTemplate/api/v1/order/posts/")
    Call<Post> createPost(@Body ArrayList<Post> post);
}
Azy

You have to create a class for credentials just like you made a class for your array. Then you create another class named lets say "Request" and put credentials and your array in it like so:

public class Request {
    final ArrayList<Post> posts;
    final Credentials credentials;

    //constructor, getters/setters
    ...

and then in your api do this:

public interface JsonPlaceHolderApi {

    @POST("hws/hibisWsTemplate/api/v1/order/posts/")
   Call<Post> createPost(@Body Request post);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Parsing JSON objects to post

Convert Json to two possible objects

Is it possible to attach file in POST Json?

Is it possible to reference a property in package.json

Conan package manager and CMakePresets.json? Is it possible?

Node Package - Is it possible to interpolate a variable in package.json?

Is it possible to create json keys as typescript objects?

Is it possible to do transpositions of big.matrix objects from the bigmemory package?

Post Multiple JSON Objects Simultaneously with Express and Postman

Spring REST - Post combinate JSON (multiple objects)

Python Flask post and return json objects

How to post JSON array of objects using JQuery

json post nested objects in swift using alamofire

Is it possible to run package.json scripts from a Node script?

Is it possible to not generate package-lock.json with npm 5?

Is it possible to set a dotenv variable from package.json script?

Is it possible to specify a npm module version without updating package.json?

Is it possible to host MERN application on Heroku using single package.json?

Node program/module reading its own package.json: is that possible?

Is it possible to consume environment variables inside of npm / package.json?

Is it possible to make Typescript aware of the dependency versions defined in the package.json?

HTTR package POST command not returning json from REST API

With Jackson JSON library, is it possible to convert custom Objects into a string and receive a string?

Is it possible to serialise a comma delimited list of single JSON objects to a collection in Java?

How to Post this kind of objects to Json from Android Application?

How to get the list of objects from POST request in Json format

"unexpected end of JSON input" when an array of objects is passed in POST request

Converting POST data from json-text to PHP objects?

angularjs - POST an array of objects(JSON data) to a PHP page