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

send parameters json with GET #125

Open
chuntin opened this issue Sep 27, 2017 · 1 comment
Open

send parameters json with GET #125

chuntin opened this issue Sep 27, 2017 · 1 comment

Comments

@chuntin
Copy link

chuntin commented Sep 27, 2017

Hi, i need to do this;
curl -v -i -k -H "Content-Type: text/html" http://localhost:8069/api/res.partner -X GET -H "access_token: XXXXXXXXXXXXXXXXX" -d '{"filters": "[(\"name\", \"like\", \"company\"), (\"id\", \"<=\", 50)]"}'

how could i do that?

Thank you

@chuntin
Copy link
Author

chuntin commented Sep 27, 2017

I have this:
$params = ['filters' => "[('country_id', '=', 69')]"]; $body = Unirest\Request\Body::Json($params); $response = Unirest\Request::get($this->url.':'.$this->port.'/api/res.country.state', $this->headers, $body);
but it, doesn't send any parameters.
the api that i try to request request me a GET method with params in a json format
works good with:
` $params = ['filters' => "[('country_id', '=', 69)]"];
$curl = curl_init();

    curl_setopt_array($curl, [
        CURLOPT_PORT => $this->port,
        CURLOPT_URL => $this->url.'/api/res.country.state',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'GET',
        CURLOPT_POSTFIELDS => json_encode($params),
        CURLOPT_HTTPHEADER => [
            'access_token: '.$this->accessToken,
            'content-type: text/html'
        ],
    ]
    );

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);`

@chuntin chuntin changed the title GET with -d parameters send parameters json with GET Sep 27, 2017
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