POST raw data Using Retrofit

Viewed 2008

I'm trying to POST raw data using Retrofit.

I found many solution to POST JSON in Body using volley but the data I'm sending is not JSON. my data is : {project_purpose: [EXECUTION]}

while hitting from the postman, I'm getting the data but not in android.

Please suggest me how to do this.

I'm trying to send as string but getting 500 in error code

I've also send the data in JsonObject, but not working..

Here is my code to call..

 String bodyST = "{project_purpose: [purpose]}";

 OR

 JsonObject data = new JsonObject();
 JSONArray jarray = new JSONArray();
 jarray.put("EXECUTION");
 data.addProperty("project_purpose", String.valueOf(jarray));


 Call<JsonArray> call = apiInterface.getData(mAuthToken, "application/json", bodyST);
2 Answers

Just send your body as string

@PUT("your-endpoint")
fun yourRequsetFunction(@Body body : String) :Response<YourResponseType>
Related