Answer the question
In order to leave comments, you need to log in
Why is json not being sent via CURL POST (PHP)?
Hello, I can’t send a request to QIWI API using PHP using Curl (Post)
By mistake, I realized that I was not passing Json correctly, but somehow I can’t solve this problem ((
{"message":"Invalid Json: No content to map due to end-of-input\n at [Source: [email protected]; line: 1, column: 0]"}1
$data = '{"id":"83278954723985","sum":{"amount":1.50,"currency":"643"},"paymentMethod":{"type":"Account","accountId":"643"},"comment":"test","fields":{"account":"+79024049398"}';
if ($curl = curl_init()) {
curl_setopt($curl, CURLOPT_URL, 'https://edge.qiwi.com/sinap/api/v2/terms/99/payments');
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Bearer api_key','Content-type: application/json','Host: edge.qiwi.com'));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_decode($data));
echo $response = curl_exec($curl);
curl_close($curl);
}
Answer the question
In order to leave comments, you need to log in
Well, it is clearly written - Invalid Json. Your $data is missing a closing curly brace at the end.
Now: ..."+79024049398"}
.
Should be: ..."+79024049398"}}
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question