Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid form encoding! for simple query #78

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

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant