I'm trying to make a callout to a Stripe Api with Apex. I made the exactly same request in Postman with the same Http configuration and have this working well. But when running it with Apex i get a Http 400 (Bad Request) with this error message:
{
"error": {
"message": "This property cannot be expanded (data).",
"type": "invalid_request_error"
}
}
What I want to do is to query a list of Payment Intents from stripe and expand the balance transaction stored in the payment charge data. And here is how I do it
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setHeader('Authorization', 'Bearer Token');
request.setHeader('Content-Type', 'application/x-www-form-urlencoded');
String payload = 'expand[]=data.charges.data.balance_transaction';
request.setMethod('GET');
request.setEndpoint(API_ENDPOINT + '/v1/payment_intents');
request.setBody(payload);
HttpResponse response = http.send(request);
System.debug(response.getBody());
Can anyone help me please to understand what I am missing here?
request.setHeader('Authorization', 'Bearer '+TokenVARIABLE);
?GET
with body. That's why they're failing, those requests are actually sent asPOST
which the external system doesn't recognise.GET
on a single payment_intent withexpand[]=charges.data.balance_transaction
as body I have the result and my balance_transaction is expanded as wished. And my logs also tell me that the callout made is aGET
. But if Salesforce really change my request Method do you know a way to make aGET
to an API wanted us to give a body to the request? ThanksPOST
method give me the same errors. So is there any way to byparse that or that is just impossible with saleforces?