Undefined offset: 1 while registering user from Services

Hi, We had a script which was registering user through Server Side script which looks like this

$options = [];
$options['headers'] = [];
$options['headers']['X-DreamFactory-Api-Key'] = $platform['session']['api_key'];
$options['headers']['X-DreamFactory-Session-Token'] = $platform['session']['session_token'];
$options['headers']['Content-Type'] = 'application/json';


$api = $platform["api"];
$post = $api->post;

$userData = [
              'last_name' => "string",
              'first_name' => "string",
              'email' => "someemail",
              'display_name' => "string"
        ];
        
$insertResponse = $post('user/register',$userData,$options);

The above code was working till we upgraded DF, now we are always getting Undefined offset: 1, not able to get pointers what could be causing this? Strangely everything else is working as before, but only register is not working.

Looking for Help.

I end up using curl like this…

function curl_post($url,$payload,$options){
    
        $headers = [
            'X-DreamFactory-Api-Key:'.$options['headers']['X-DreamFactory-Api-Key'].'',
            'X-DreamFactory-Session-Token:'.$options['headers']['X-DreamFactory-Session-Token'].'',
            'Content-type:application/json'
        ];
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, TRUE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    
        $curlresponse = curl_exec($ch);
        curl_close($ch);
        
        return $curlresponse;
}

$baseurl="baseserviceurl";

$options = [];
$options['headers'] = [];
$options['headers']['X-DreamFactory-Api-Key'] = $platform['session']['api_key'];
$options['headers']['X-DreamFactory-Session-Token'] = $platform['session']['session_token'];
$options['headers']['Content-Type'] = 'application/json';

$userData = [
              'last_name' => "string",
              'first_name' => "string",
              'email' => "someemail",
              'display_name' => "string"
        ];
        
$insertResponse = curl_post($baseurl.'user/register',$userData,$options);

Hope it helps someone with similar problem.

2 Likes