Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: REST Api doc curl examples do not work in Windows #9

Open
8ctopus opened this issue Sep 26, 2023 · 4 comments
Open

[Bug]: REST Api doc curl examples do not work in Windows #9

8ctopus opened this issue Sep 26, 2023 · 4 comments
Assignees
Labels
api This issue is specific to PayPal APIs bug Something isn't working

Comments

@8ctopus
Copy link

8ctopus commented Sep 26, 2023

Contact Details

[email protected]

Describe the Issue

curl examples do not work on Windows. Here's an example taken from the documentation:

https://developer.paypal.com/api/rest/authentication/
curl -v -X POST "https://api-m.sandbox.paypal.com/v1/oauth2/token"\
 -u "CLIENT_ID:CLIENT_SECRET"\
 -H "Content-Type: application/x-www-form-urlencoded"\
 -d "grant_type=client_credentials"

Copy and pasting this in a Windows command line leads to the following output:

K:\downloads>curl -v -X POST "https://api-m.sandbox.paypal.com/v1/oauth2/token"\
*   Trying 199.232.169.35:443...
* Connected to api-m.sandbox.paypal.com (199.232.169.35) port 443 (#0)
* schannel: disabled automatic use of client certificate
* ALPN: offers http/1.1
* ALPN: server accepted http/1.1
* using HTTP/1.1
> POST /v1/oauth2/token\ HTTP/1.1
> Host: api-m.sandbox.paypal.com
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 400 Bad Request
< Connection: keep-alive
< Content-Length: 435
< Content-Type: text/html;charset=utf-8
< Server: nginx
< Cache-Control: max-age=0, no-cache, no-store, must-revalidate
< Content-Language: en
< Paypal-Debug-Id: 45d637c97df00
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Accept-Ranges: bytes
< Via: 1.1 varnish, 1.1 varnish
< Edge-Control: max-age=0
< Date: Tue, 26 Sep 2023 03:58:58 GMT
< X-Served-By: cache-lhr7327-LHR, cache-par-lfpg1960041-PAR
< X-Cache: MISS, MISS
< X-Cache-Hits: 0, 0
< X-Timer: S1695700738.861618,VS0,VE482
< Vary: Accept-Encoding
<
<!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>* Connection #0 to host api-m.sandbox.paypal.com left intact

K:\downloads> -u "CLIENT_ID:CLIENT_SECRET"\
'-u' is not recognized as an internal or external command,
operable program or batch file.

K:\downloads> -H "Content-Type: application/x-www-form-urlencoded"\
'-H' is not recognized as an internal or external command,
operable program or batch file.

K:\downloads> -d "grant_type=client_credentials"

Correct output gets displayed if \ is replaced by ^

curl -v -X POST "https://api-m.sandbox.paypal.com/v1/oauth2/token" ^
 -u "CLIENT_ID:CLIENT_SECRET" ^
 -H "Content-Type: application/x-www-form-urlencoded" ^
 -d "grant_type=client_credentials"
K:\downloads>curl -v -X POST "https://api-m.sandbox.paypal.com/v1/oauth2/token" ^
More?  -u "CLIENT_ID:CLIENT_SECRET" ^
More?  -H "Content-Type: application/x-www-form-urlencoded" ^
More?  -d "grant_type=client_credentials"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 199.232.169.35:443...
* Connected to api-m.sandbox.paypal.com (199.232.169.35) port 443 (#0)
* schannel: disabled automatic use of client certificate
* ALPN: offers http/1.1
* ALPN: server accepted http/1.1
* using HTTP/1.1
* Server auth using Basic with user 'CLIENT_ID'
> POST /v1/oauth2/token HTTP/1.1
> Host: api-m.sandbox.paypal.com
> Authorization: Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=
> User-Agent: curl/8.0.1
> Accept: */*
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 29
>
< HTTP/1.1 401 Unauthorized
< Connection: keep-alive
< Content-Length: 77
< Content-Type: application/json
< Server: nginx
< Cache-Control: max-age=0, no-cache, no-store, must-revalidate
< Paypal-Debug-Id: 1cf300fcf12d3
< Pragma: no-cache
< X-Paypal-Token-Service: IAAS
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Accept-Ranges: bytes
< Via: 1.1 varnish, 1.1 varnish
< Edge-Control: max-age=0
< Date: Tue, 26 Sep 2023 04:17:49 GMT
< X-Served-By: cache-lhr7370-LHR, cache-par-lfpg1960057-PAR
< X-Cache: MISS, MISS
< X-Cache-Hits: 0, 0
< X-Timer: S1695701869.999422,VS0,VE594
< Vary: Accept-Encoding
<
{"error":"invalid_client","error_description":"Client Authentication failed"}* Connection #0 to host api-m.sandbox.paypal.com left intact

Steps To Reproduce

See above

What type of Operating System are you seeing the problem on?

Windows

What type of browser are you seeing the problem on?

N/A

Screenshots or Videos

No response

Code to produce this issue.

No response

@8ctopus 8ctopus added the bug Something isn't working label Sep 26, 2023
@devchristina devchristina self-assigned this Sep 26, 2023
@devchristina devchristina added the api This issue is specific to PayPal APIs label Sep 26, 2023
@devchristina
Copy link
Contributor

Sent this to the team to triage.

@devchristina
Copy link
Contributor

@8ctopus -- Here's what I'm getting from the team:

It's true that curl samples need to adjusted for terminals of idiosyncratic operating systems, such as Windows. Currently our documentation site does not have the capability to toggle & select different OS to view the samples. If you don't want to adjust the samples, the suggestion would be to use WSL to run them.

In your opinion, is this a nice feature to have or do you find that other companies are providing this type of capability?

@8ctopus
Copy link
Author

8ctopus commented Sep 29, 2023

IMO, the samples should work whatever platform the developer is using and it's not that it is not a problem that is hard to fix. You re just telling developers to use your competitors instead. There are way too many bugs at the moment as you have seen from the issues I have posted in the last week.

@devchristina
Copy link
Contributor

We don't see that competitors are doing it any different. None the less, we take this feedback seriously and I'll challenge the team to come up with a solution. You've helped tremendously this week with the bugs and while true to say it's been a lot, your effort to call them out and notify us is truly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api This issue is specific to PayPal APIs bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants