[PHP][Web Apps] The request contains 1 tokens separated by '=' instead of a single key value pair. RRS feed

  • Question

  • I dont know which one is the right place to post below query.

    I am trying to call restAPI which is protected by ACS . When I call this api it return below.

    PHP Code

    $temp = array('wrap_name'=>$wrap_name,'wrap_password'=>$wrap_password,'wrap_scope'=>$wrap_scope);
    $temp = http_build_query($_POST);
    $ch = curl_init();    
             // initiate curl
    curl_setopt($ch, CURLOPT_URL,$baseAdress);
    curl_setopt($ch, CURLOPT_POST, true);  // tell curl you want to post something
    curl_setopt($ch, CURLOPT_POSTFIELDS, $temp); // define what you want to post
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    $output = curl_exec ($ch); // execute

    if($output === false)
    echo 'Curl error: ' . curl_error($ch);

    curl_close ($ch); // close curl


    Error:Code:400:SubCode:T0:Detail:ACS90004: The request contains 1 tokens separated by '=' instead of a single key value pair.

    Can anyone please help me with above


    Monday, March 21, 2016 3:43 PM


  • According your error message, you can try to remove the sentence "$temp = http_build_query($_POST);", as the function http_build_query will return a URL-encoded query string like "foo1=bar1&foo2=bar2".  

    You can try to directly post the array data in cURL closures. 

    Meanwhile, you can use file_get_contents() with http_build_query() to post data, refer to for the answer on SO.

    Furthermore, when we implement with REST APIs, there should be references for these APIs, we need to follow these reference to build our code project.

    Tuesday, March 22, 2016 1:50 AM