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[]

5
  • Can you add more information? What does postWithFields do? What is the output - some exception? Something else? Commented Feb 12, 2019 at 20:43
  • See: stackoverflow.com/a/14395679/10792833 Commented Feb 12, 2019 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. Commented Feb 12, 2019 at 20:45
  • You pass an array instead of an object in user field, might be the problem? Commented Feb 12, 2019 at 20:48
  • @guyaloni so should be 'user' => (object)['Password' => 'Password123'] ? Commented Feb 12, 2019 at 21:07

1 Answer 1

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'
                ],
            ]
        ],
    ],
];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.