Needing to add a dynamic job Id to the uri using Guzzle 7

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' => '',
       ['headers' => [
           'Accept' =>'application/json'

here is the promise:

$promise = $client->requestAsync('GET', 'jobs/', ['query' => [

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' => [

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.


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' => [

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x