The request body contains bad syntax or is incomplete error found while making a transfer through curl in sandbox

Hello,
I am trying to initiate a transfer with the transfer API in sandbox. I have retrieved source and destination funding sources and prepared the request body. I am facing: The request body contains bad syntax or is incomplete error. My request body is as below:

$data_string = '{
        "_links": {
            "source": {
                "href": "'.$source.'"
            },
            "destination": {
                href": "'.$dest.'"
            }
        },
        "amount": {
            "currency": "USD",
            "value": "'.$amt.'"
         }
     }';
$ch4 = curl_init("https://api-sandbox.dwolla.com/transfers");
        curl_setopt($ch4, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch4, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch4, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch4, CURLOPT_HTTPHEADER, array(
                           'Content-Type: application/vnd.dwolla.v1.hal+json',
                           'Accept: application/vnd.dwolla.v1.hal+json',
                           'Authorization: Bearer '.$token.'',
                           'Idempotency-Key: '.$myuuid.''
                           )
         );
        $result4 = curl_exec($ch4);
        $result4 = json_decode($result4);

Where am I doing wrong? Please help.

Hi @symapptest5

The structure of the JSON request-body looks good to me. Perhaps it could be what’s being populated in the variables .$source, .$dest or .$amt that causing the BadSyntax error.

Are you able to share the raw request and response bodies? If you could share the request-id (from the X-request header) I can look up this request on my end as well and see what’s populating for us in the request-body!