Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Invalid form encoding! for simple query #78

Closed
jbouzekri opened this issue Oct 7, 2020 · 0 comments
Closed

Invalid form encoding! for simple query #78

jbouzekri opened this issue Oct 7, 2020 · 0 comments

Comments

@jbouzekri
Copy link

I have an Alfresco 9.0.0 installation and I am simply trying to get all the documents.

$httpInvoker = new \GuzzleHttp\Client(
    array(
        'defaults' => array(
            'auth' => array(
                CMIS_BROWSER_USER,
                CMIS_BROWSER_PASSWORD
            )
        )
    )
);

$parameters = array(
    \Dkd\PhpCmis\SessionParameter::BINDING_TYPE => \Dkd\PhpCmis\Enum\BindingType::BROWSER,
    \Dkd\PhpCmis\SessionParameter::BROWSER_URL => CMIS_BROWSER_URL,
    \Dkd\PhpCmis\SessionParameter::BROWSER_SUCCINCT => false,
    \Dkd\PhpCmis\SessionParameter::HTTP_INVOKER_OBJECT => $httpInvoker,
);

$sessionFactory = new \Dkd\PhpCmis\SessionFactory();

// If no repository id is defined use the first repository
if (CMIS_REPOSITORY_ID === null) {
    $repositories = $sessionFactory->getRepositories($parameters);
    $parameters[\Dkd\PhpCmis\SessionParameter::REPOSITORY_ID] = $repositories[0]->getId();
} else {
    $parameters[\Dkd\PhpCmis\SessionParameter::REPOSITORY_ID] = CMIS_REPOSITORY_ID;
}

$session = $sessionFactory->createSession($parameters);
$result = $session->query('SELECT * FROM cmis:document');

It errored with :

{"exception":"invalidArgument","message":"Invalid form encoding!"}

This is the generated url and it makes a POST on it : /alfresco/api/-default-/public/cmis/versions/1.1/browser?cmisaction=query&statement=SELECT%20%2A%20FROM%20cmis%3Adocument&searchAllVersions=false&includeAllowableActions=true&renditionFilter=cmis%3Anone&skipCount=0&dateTimeFormat=simple&includeRelationships=none&maxItems=100

I found this article https://stackoverrun.com/ru/q/11802324 which says if you are doing POST, you should put the request in the body, not the url.

And indeed, if I do a curl http://mydomain/alfresco/api/-default-/public/cmis/versions/1.1/browser -d 'cmisaction=query&statement=SELECT%20%2A%20FROM%20cmis%3Adocument&searchAllVersions=false&includeAllowableActions=true&renditionFilter=cmis%3Anone&skipCount=0&dateTimeFormat=simple&includeRelationships=none&maxItems=100' it works great.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants