Can't Create Subscription Product

ipconfigurable
New Community Member

I've been trying to create a subscription product for a button on my webpage but have run into some errors that I can't seem to find answers for on Google.

 

What I have tried:

 

I retrieved an access token using this command from this page

 

 

curl -v https://api.sandbox.paypal.com/v1/oauth2/token -H "Accept: application/json" -H "Accept-Language: en_US" -u "client_id:secret" -d "grant_type=client_credentials"

 

 

(I removed the slashes “\” at the line endings and moved everything to one line because the command prompt didn’t seem to run them correctly. I also replaced “client_id” with my app id and “secret” with my app secret leaving the colon between them).

 

That gave me this:

 

 

{"scope":"https://uri.paypal.com/services/invoicing https://uri.paypal.com/services/disputes/read-buyer https://uri.paypal.com/services/payments/realtimepayment https://uri.paypal.com/services/disputes/update-seller https://uri.paypal.com/services/payments/payment/authcapture openid https://uri.paypal.com/services/disputes/read-seller https://uri.paypal.com/services/payments/refund https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/payments/.* https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.* https://uri.paypal.com/services/subscriptions https://uri.paypal.com/services/applications/webhooks","access_token":"A21AAFhs-YZory3SFkTsoj_oHmJ9ix5oVWdrclEJ7Xtqvt15A6LlbRPZhBS391z6Jzs3Kb30aYzaHbbNF9XPEjTPCCWoDokBA","token_type":"Bearer","app_id":"removed","expires_in":32400,"nonce":"2019-12-27T00:35:26ZvOsLgtjrs2Sx7Gz1rUyiAQuvJwLKSPvEZbZP2_Ud0MQ"}

 

 

 

I use the generated access token in the next command.

 

Then I tried to use the command from this page:

 

 

curl -v -X POST https://api.sandbox.paypal.com/v1/catalogs/products -H "Content-Type: application/json" -H "Authorization: Bearer A21AAFhs-YZory3SFkTsoj_oHmJ9ix5oVWdrclEJ7Xtqvt15A6LlbRPZhBS391z6Jzs3Kb30aYzaHbbNF9XPEjTPCCWoDokBA" -d '{"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"}'

 

 

Which gave me this:

 

 

{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"da8f20e6f976e","details":[{"location":"body","issue":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') line: 1, column: 2"}],"links":[]}

 

 

So then I tried removing the “Bearer” part of the access token (I thought it might be throwing off the syntax checker or something). That gave me this:

 

 

{"name":"AUTHENTICATION_FAILURE","message":"Authentication failed due to invalid authentication credentials or a missing Authorization header.","links":[{"href":"https://developer.paypal.com/docs/api/overview/#error","rel":"information_link"}]}

 

 

So I’m kind of at a loss here. Maybe I need to look into the forward slashes not working properly? Or is there some blatant error I’m making that I’m unaware of?

 

Thank you for any assistance you can provide.


Login to Me Too
2 REPLIES 2

AvWoN
Contributor
Contributor

Have you figured it out since? Im running into the same issue in the same exact way. I find it odd that there is no mention as to the formatting of the commands. It feels like simply using curl and these commands is not the only requirement.

Login to Me Too

coords-zz
Contributor
Contributor

This was giving me fits as well.  I was about to give up, or try it without a sandbox but attempted one last time and got it to go.  Eyebaling it not sure what minor difference between your post and the one that worked for me is.  I have line breaks with the \ for the headers.  I included a Paypal-Request-id though the response ended up ignoring it and generating its own.  Mine, with the creds being replaced with xxxx though note there is a space between end of token and the closing ":

 

curl -v -X POST https://api-m.sandbox.paypal.com/v1/catalogs/products \
-H "Content-Type: application/json" \
-H "Authorization: Bearer xxxx " \
-H "PayPal-Request-Id: SB-PRODUCT-001" \
-d '{ "name": "SB-WF-Premium", "description": "Ad-free content. Additional features in development.", "type": "DIGITAL", "category": "COMMERCIAL_SPORTS_PROFESSIONA", "image_url": "xxxx.png","home_url": "https://xxxxx" }'

 

Good luck

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.