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

Headers and query params #23

Open
StalkAlex opened this issue Oct 31, 2018 · 7 comments
Open

Headers and query params #23

StalkAlex opened this issue Oct 31, 2018 · 7 comments

Comments

@StalkAlex
Copy link

How can I pass them? Could you show an example please?

@calebtr
Copy link

calebtr commented Jan 14, 2019

If it is helpful, I was able to pass headers this way:

$odataClient = new ODataClient($serviceURL, function($request) {
    $request->headers['APIKEY'] = 'SuperDuperSecretKey';
});

For query parameters I use ->where() for oData's filter.

@StalkAlex
Copy link
Author

StalkAlex commented Jan 15, 2019

Thanks for the hint! It could be done like this, but in my case I need to change them every time before a new request. So I solved this problem by creating ODataRequest instance for every request. But this is not an ideal solution.

@anderly
Copy link
Member

anderly commented Jan 30, 2019

@StalkAlex, thanks for opening this.

I think we can achieve this by adding a headers or withHeaders method onto the QueryBuilder to allow for appending to/modifying the headers collection set on the ODataRequest.

Can you give an example of the headers you're wanting to set? Just curious.

@StalkAlex
Copy link
Author

StalkAlex commented Feb 11, 2019

@anderly currently I found way to get around this problem. Here's my way and example of the header

            $request = new ODataRequest('POST', $requestUrl, $this->client);
            $request->addHeaders([
                'Content-Type' => 'text/xml'
            ]);
            $request->attachBody($fileContent);
            $response = $request->execute();

@solokhind
Copy link

So how do I add a custom parameter to query?

For example I need:
https://api.domain.com/v1/Orders?exported=false

@manojiksula
Copy link

manojiksula commented Oct 14, 2021

getting below error while query, can you help me with solution
#message: "cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)" #code: 0 #file: "C:\wamp64\www\drupal\xxx\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php"

@anderly
Copy link
Member

anderly commented Oct 14, 2021

@manojiksula, that's unrelated to this package, but see here for how to resolve your certificate issue https://stackoverflow.com/a/31830614

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

No branches or pull requests

5 participants