Tom Shaw
Tom Shaw

Reputation: 1712

PayPal API V2 Create Invoice Wrong Response/Status Code

I'm getting the wrong response/status code when creating an invoice using PayPal API V2. I'm getting status code 200 instead of 201 that produces the following response. According to the docs should be returning a Created status code 201 and a JSON response body that shows invoice details

"rel" => "self"
"href" => "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2LMY-9VSE-KKRR-RGYP"
"method" => "GET"  

Upvotes: 1

Views: 226

Answers (1)

Preston PHX
Preston PHX

Reputation: 30377

200 and 201 are essentially interchangeable. The documentation states:

A successful request returns the HTTP 200 OK status code and a JSON response body that shows template details if you set prefer=return=representation.

The format of that HTTP header string should be Prefer: return=representation

The default is return=minimal, which will only contain the GET link.

Upvotes: 2

Related Questions