Creating API Session

dovevgo17 years ago

Hi,

I'm trying to create and API session call and keep getting HTTP 401 Unauthorized - WebApplicationException (SessionResource:108 < ...)

I have a user a@bb.com with password 1q2w3e4r

This is my curl call:

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "2052",
  CURLOPT_URL => "http://myserver.com:2052/api/session",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Basic YUBiYi5jb206MXEydzNlNHI=",
    "content-type: application/x-www-form-urlencoded"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

What am I missing?

Anton Tananaev7 years ago

You have to send login and password as form parameters in the post, not authorization header.