0

I'm having a bit of an issue with an API document I'm currently working with. The code I've been testing just doesn't seem to work, and I've been looking at it for that long now, I just cannot see where I'm going wrong.

API Documentation Screenshot here: https://ibb.co/CW4HRR9

// POST /package/{id}/web/ftpusers
$args = [
    'update' => [
        'ftp' => [
            'id' => '12345',
            'user' => ['Password' => 'Password123']
        ],
    ],
];
$response = $services_api->postWithFields("/package/".$test_domain_id."/web/ftpusers", $args);
echo '<pre>';
print_r($response);
echo '</pre>';

It just doesn't seem to work, and I'm guessing I'm doing something wrong where it states object and object[]

James Simpson
  • 197
  • 2
  • 16
  • Can you add more information? What does `postWithFields` do? What is the output - some exception? Something else? – guyaloni Feb 12 '19 at 20:43
  • See: https://stackoverflow.com/a/14395679/10792833 – Yan Feb 12 '19 at 20:44
  • @guyaloni That is just a class, and is out of scope of this as postWithFields works in a query to get $test_domain_id - I have a feeling its in the $args that the issue falls, with the screenshot documentation (link above). The output is supposed to be an array with a id and confirmation its worked, but its blank for above. – James Simpson Feb 12 '19 at 20:45
  • You pass an array instead of an object in user field, might be the problem? – guyaloni Feb 12 '19 at 20:48
  • @guyaloni so should be 'user' => (object)['Password' => 'Password123'] ? – James Simpson Feb 12 '19 at 21:07

1 Answers1

0

Looks like I was missing an array object as I've now got this working (extra array within 'ftp'

$args = [ 
    'update'=> [
        'ftp' => [ 
            [
            'id' => $info[0]->Id,
            'user' => [
                'Enabled' => true,
                'Password' => 'Password123'
                ],
            ]
        ],
    ],
];
James Simpson
  • 197
  • 2
  • 16