Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paypal UNSUPPORTED_MEDIA_TYPE

Tags:

fetch

paypal

I am trying to get an access token from paypal's authorization api. When I make post request to the api I get UNSUPPORTED_MEDIA_TYPE i.e. 415 response.

Below is the snippet that I used.

const auth = await fetch(PAYPAL_OAUTH_API, {
    method: 'post',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Basic ${ basicAuth }`
    },
    body: JSON.stringify({"grant_type": "client_credentials"})
});
like image 442
Asur Avatar asked Feb 14 '19 05:02

Asur


1 Answers

I have fixed my issue by setting Content-Type to application/x-www-form-urlencoded.

My guess is paypal accepts only application/x-www-form-urlencoded for authorization api.

like image 195
Asur Avatar answered Oct 08 '22 09:10

Asur