Im passing in a job Id that dynamically needs to populate the uri in guzzle 7 here is the client:
$client = new GuzzleHttpClient([ 'base_uri' => 'https://portal.2nformserver.com/arcgis/rest/services/getLocalRefData/GPServer/Get%20Local%20Reference%20Data/', ['headers' => [ 'Accept' =>'application/json' ]] ]);
here is the promise:
$promise = $client->requestAsync('GET', 'jobs/', ['query' => [ "f"=>"json" ]]);
I am needing to pass in a $jobId variable into the Uri portion of the request. I have not been able to find a way to do this. I was hoping for something as easy as:
$promise = $client->requestAsync('GET', 'jobs/{$jobId}', ['query' => [ "f"=>"json" ]]);
or to be able to add something to the array I could pass in but have come up with no answers any help would be greatly appreciated.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
you can pass variable to uri using php string format:
$promise = $client->requestAsync('GET', "jobs/$jobId", ['query' => [ "f"=>"json" ]]);
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0