Community Forums

Where our customers, developers, and more can come together to help each other with both general and technical questions about our products and services.

PHP - While creating pass from Wallet API getting an error "Error parsing JSON request string,msg= null"

Mohit Saini


With PHP, i am trying to generate pass from one of the template of  my project. Below is my code, which is  not working. Use below code, change template id, login email and API key to check this.



    $fields = array(
        'publicURL' => 'single',
        'msg' => 'Testing msg only.',
        'Passenger' => 'Test Passenger',
        'Boarding Pass Details' => 'This text is automated'
    $create_pass = get_curl_data('', $fields);
    $create_passArr = json_decode($create_pass);
    echo rand();
    echo '<pre>';
    echo '</pre>';

    function get_curl_data($url, $fields){
        //open connection
        $ch = curl_init();
        //set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_USERPWD, 'xxxxLOGINEMAILxxxx:xxxxAPIKEYxxxx');
        curl_setopt($ch,CURLOPT_URL, $url);
        curl_setopt($ch,CURLOPT_POST, count($fields));
        curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($fields));

        //curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded', 'Api-Revision:1.2'));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);

        //execute post
        $result = curl_exec($ch);
        //close connection
        return $result;



After executing above code, i am getting below error message.

stdClass Object
    [code] => 406
    [description] => Not Acceptable Request.
    [details] => Error parsing JSON request string,msg= null


Can anyone help me on this?



Please sign in to leave a comment.


I resolve it. Just replace below lines with current code.

$json_data = json_encode($fields);
curl_setopt($ch,CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Content-Length: ' . strlen($json_data) , 'Api-Revision:1.2'));


Hope this helps.


Mohit Saini 0 votes

Hi Mohit,

Thank you for providing the resolution in this forum.

Please let us know if there is any more we can do.

My Best,
Aaron Schuman
Technical Support Engineer, Portland


Aaron S. 0 votes