- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, i'm trying to create a subscription via REST api. I succesfully retrieved my token, then i tried to add the product but if i try from php it retrieve 401 error, and via postman it says "UNSUPPORTED_MEDIA_TYPE". i don't understand if i need to create some other things before product, or if this passage is mandatory in order to make the user subscribe to my subscription.
this is my php code, i'm using symfony6.0
any advice will be helpful, thanks to all
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This works.
You could test with the following PHP. Just replace YOUR_BEARER_TOKEN with your own Bearer token.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api-m.sandbox.paypal.com/v1/catalogs/products',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"name": "Video Streaming Service",
"description": "Video streaming service",
"type": "SERVICE",
"category": "SOFTWARE",
"image_url": "https://example.com/streaming.jpg",
"home_url": "https://example.com/home"
}',
CURLOPT_HTTPHEADER => array(
'Accept-Language: en_US',
'Accept: application/json',
'Authorization: Bearer YOUR_BEARER_TOKEN',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @alex313962 ,
Can you try using Content-Type: application/json?
Thank you.
Powered by Custom Software : NexWebSites.com
PayPal Developers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, at first i tried with application/josn, after that i found a stackoverflow that suggest me to use this. it doesn't work in both cases
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This works.
You could test with the following PHP. Just replace YOUR_BEARER_TOKEN with your own Bearer token.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api-m.sandbox.paypal.com/v1/catalogs/products',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"name": "Video Streaming Service",
"description": "Video streaming service",
"type": "SERVICE",
"category": "SOFTWARE",
"image_url": "https://example.com/streaming.jpg",
"home_url": "https://example.com/home"
}',
CURLOPT_HTTPHEADER => array(
'Accept-Language: en_US',
'Accept: application/json',
'Authorization: Bearer YOUR_BEARER_TOKEN',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Webhook Data Discrepancies Between Live and Sandbox Environments in REST APIs
- Subscription in Sandbox gives : We’re sorry Things don’t appear to be working at the moment in Sandbox Environment
- Paypal scope is not allowing us to include additional params. in REST APIs
- App selection for Subscription Button in Sandbox Environment
- I want to implement subscription functionality. in REST APIs