How to get the full json of the query?

Hi,

I’m trying to implement the scim protocol in an scim service provider app.
When I add a user, the json I’m posting looks like this:

{
	"schemas": [
		"urn:ietf:params:scim:schemas:core:2.0:User"
	],
	"active": true,
	"id": "test2",
	"userName": "test2",
	"emails": [
		{
			"primary": true,
			"value": "tes2t@example.net"
		}
	],
	"displayname": "test2"
}

I used the app “provisionning_api” as a base, and my method looks like this:

	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 *
	 * @param string $id
	 * @param string $displayName
     * @param array $emails
	 * @param array $groups
	 * @return DataResponse
	 * @throws OCSException
	 */
	public function addUser(string $id,
							string $displayname = '',
							array $emails = [],
							array $groups = [],
							array $subadmin = [],
							string $quota = '',
							string $preferredLanguage = ''): DataResponse {
...

I manage to map all params, but I struggle with the email array part.

How could I access the full json?
Or How could I access the email value with the 'primary': true ?

Thanks for your help!

I looked at this:

It didn’t help me :slight_smile:

I’m trying to log to get a sense of what is the object:

		$this->logger->error('Log email: ' . array_values($emails)[0], ['app' => 'ocs_api']);

But I get this:

{"reqId":"tGex5C0tsPCTw7uIdVJi","level":3,"time":"2022-04-28T08:54:59+00:00","remoteAddr":"192.168.21.5","user":"admin","app":"ocs_api","method":"POST","url":"/index.php/apps/scimserviceprovider/users","message":"Log email: Array","userAgent":"insomnia/2022.2.1","version":"22.2.7.1"}

Is there a better way to debug? Like a remote debug? Of at least a way to print the full object in the log?

FYI, I’m using the GitHub - juliushaertl/nextcloud-docker-dev: Nextcloud development environment using docker-compose as a dev env for my app dev :slight_smile:

Ok, I managed to make it work after some trying.

			foreach ($emails as $email) {
				$this->logger->error('Log email: ' . $email['value'], ['app' => 'ocs_api']);
				if ($email['primary'] === true) {
					$newUser->setEMailAddress($email['value']);
				}
			}

Basically I was expecting an object $email->value and not an array $email['value'].

But I found it, and I’m happy!

Next step for me would be to setup a remote debugger, this would have saved me some time I guess :slight_smile:

1 Like