0
votes

I followed the example on https://developer.paypal.com/docs/integration/direct/create-single-payout/ but keep getting this error:

Array ( [name] => MALFORMED_REQUEST_ERROR [message] => Json request malformed. [debug_id] => aef61e278b531 [information_link] => https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST_ERROR )

This is the curl request:

curl -v https://api.sandbox.paypal.com/v1/payments/payouts?sync_mode=true \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Access-Token>" \
-d "{
"sender_batch_header": {
        "email_subject": "You have a payment"
    },
    "items": [
        {
            "recipient_type": "EMAIL",
            "amount": {
                "value": 12.34,
                "currency": "USD"
            },
            "receiver": "[email protected]",
            "note": "Payment for recent T-Shirt delivery",
            "sender_item_id": "A123"
        }
    ]
}"

The error docs say the JSON is malformed but then I used jsonlint to make sure its a valid JSON. What can it be?

1
If you're running it from the command line, you probably need to have backslashes before all the double quotes in the JSON. - Matt Cole
Thanks Matt. I tried that but got the same error. - Kartik kar2905
Take out the double quotes surrounding the JSON block and replace them with single quotes. - delatbabel

1 Answers

0
votes

Matt's comment about properly escaping quotes should get you going:

e.g. skipped everything so, this is just the payload/data (-d):

-d "{ \"payer_id\" : \"THE_PAYER_ID\" }"

Hth..