logo
down
shadow

In Karate DSL, How do I resolve an Unsupported Media Type for a valid POST REQUEST


In Karate DSL, How do I resolve an Unsupported Media Type for a valid POST REQUEST

By : Jossimar Vicente
Date : November 21 2020, 03:00 PM
this one helps. The moment you use replace the type is converted to string - and this is clearly mentioned in the documentation.
So you have two options: a) type-cast the result of the replace back to JSON b) set the Content-Type header manually.
code :


Share : facebook icon twitter icon
CXF 2.7.7 Unsupported Media Type : since 2.7.0 : when we post null request

CXF 2.7.7 Unsupported Media Type : since 2.7.0 : when we post null request


By : Grad student
Date : March 29 2020, 07:55 AM
it should still fix some issue I've just posted an empty body. Its not a real solution, but it does let me proceed.
Spring POST Request Unsupported Media Type 415

Spring POST Request Unsupported Media Type 415


By : knightrid
Date : March 29 2020, 07:55 AM
help you fix your problem
No suitable constructor found for type [simple type, class org.elsys.internetprogramming.trafficspy.server.Marker]
POST request returns 415 - Unsupported Media Type

POST request returns 415 - Unsupported Media Type


By : rahul gupta
Date : March 29 2020, 07:55 AM
will be helpful for those in need You want to set contentType. Your header is not formatted properly
Switch:
code :
 header: 'application/json',
contentType: "application/json;charset=utf-8",
Angular 2 - Post request - Unsupported media type when sending request to Jersey

Angular 2 - Post request - Unsupported media type when sending request to Jersey


By : JoBi
Date : March 29 2020, 07:55 AM
hop of those help? Dears, I have found the issue with the code. The problem is with both the POST method and the angular HTTP call .
1) The @POST method has been changed to below
code :
    @POST
    @Path("/saveProjectInfo/{projectId}/{application}")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @JsonRawValue
    public String saveProjectInfo(SaveBean input,
            @PathParam("projectId") String projectId,
            @PathParam("application") String application) {

        System.out.println("ProjectId provided : " + projectId);
        System.out.println("Application provided : " + application);
        System.out.println("Effort : " + input.getEffort());
        System.out.println("CRC : " + input.getCrc());

        return "Project description saved successfully";
    }
saveProjectDetails(info: any) {
    const body = JSON.stringify(info);
    const headers = new Headers();
    headers.append('Content-Type', 'application/json');
    alert(body);
    return this.http.post(this.postUrl, body, {headers: headers}).map((response: Response) => response.text());
  }
Unsupported Media type error for request.post

Unsupported Media type error for request.post


By : aza.kz
Date : March 29 2020, 07:55 AM
may help you . I am working on a api call with python. Here I have the parameters in json format that was generated in the website I am trying to access. But when I try to run the program I get an 415: unsupported Media Type error. Not sure what I am doing wrong, as I am using the parameters generated by the website.
code :
import requests
import json


def jprint(obj):
    text = json.dumps(obj, sort_keys=True, indent=4)
    print(text)


url = 'https://einv-apisandbox.nic.in/gstvital/api/auth'

parameters = {
    "header": {
        "ClientID": "TheClientIDGoesHere",
        "ClientSecret": "TheClientSecretGoesHere"
    },

    "data": {
        "UserName": "Username",
        "Password": "Password",
        "AppKey": "AppKey",
        "ForceRefreshAccessToken": False
    }
}

hdr = {"Content-Type": "application/json"}

response = requests.post(url, data=parameters, headers=hdr)

print(response.status_code)

print(response.json())
shadow
Privacy Policy - Terms - Contact Us © voile276.org