odata-client-php
odata-client-php copied to clipboard
Headers and query params
How can I pass them? Could you show an example please?
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
.
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.
@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.
@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();
So how do I add a custom parameter to query?
For example I need: https://api.domain.com/v1/Orders?exported=false
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"
@manojiksula, that's unrelated to this package, but see here for how to resolve your certificate issue https://stackoverflow.com/a/31830614