No response data on creating a job

Hi,

I’m setting up an integration using the PHP library, and can authenticate and create jobs fine (in sandbox), and receive the callbacks once a job is created. My problem is that no data is returned with the response from a successful job creation (/v2/jobs). I receive an error if unsuccessful, but the response is empty if not. Any ideas?

Hi @Tristan,
Can you share with us some details about your requests (account and information you used) so we can investigate in our logs?

We also advice checking out Starting my Integration for more details on how to best work with us to build your integration.

Hi, I’ve just sent a few job requests, account: tristan.a@nakedideas.com.

I’ve tried sending the job straight through the API and receive a response fine, but when I do it through the PHP library I receive an empty object.

Here’s the job data after going through JobToJson():
{
“job”:{
“pickups”:[
{
“address”:“147 St Johns Hill, SW11 1TQ”,
“comment”:null,
“contact”:{
“firstname”:“Tristan”,
“lastname”:“Allen”,
“phone”:null,
“email”:null,
“company”:“PowderKeg”
}
}
],
“dropoffs”:[
{
“address”:“135-137 Stephendale Rd, Fulham, SW6 2PR”,
“comment”:null,
“contact”:{
“firstname”:“Tristan”,
“lastname”:“Allen”,
“phone”:null,
“email”:null,
“company”:“The Sands End”
},
“package_type”:“small”,
“package_description”:null,
“client_reference”:null
}
]
}
}

This same data returns fine sending directly to the API through Postman.

Tristan

Hello Tristan,

Thank you for the information. We have tested your parameters using the php library, hopefully this will help you to see how it is working.

Here is the PHP code:

// setup stuart client
$environment = \Stuart\Infrastructure\Environment::SANDBOX;
$api_client_id = 'your_client_id'; // can be found here: https://dashboard.sandbox.stuart.com/settings/api
$api_client_secret = 'your_client_secret'; // can be found here: https://dashboard.sandbox.stuart.com/settings/api
$authenticator = new \Stuart\Infrastructure\Authenticator($environment, $api_client_id, $api_client_secret);
$httpClient = new \Stuart\Infrastructure\HttpClient($authenticator);
$client = new \Stuart\Client($httpClient);

// create a new job
$job = new \Stuart\Job();

$job->addPickup('147 St Johns Hill, SW11 1TQ')
    ->setContactFirstName('Tristan')
    ->setContactLastName('Allen')
    ->setContactCompany('PowderKeg');

$job->addDropOff('135-137 Stephendale Rd, Fulham, SW6 2PR')
    ->setPackageType('small')
    ->setContactCompany('The Sands End')
    ->setContactFirstName('Tristen')
    ->setContactLastName('Allen');

$created_job = client->createJob($job);

// showing the result in the console
print_r($created_job);

And here the response we’ve got in the console:

Stuart\Job Object
(
    [id:Stuart\Job:private] => 131343
    [transportType:Stuart\Job:private] => 
    [assignmentCode:Stuart\Job:private] => 
    [status:Stuart\Job:private] => searching
    [pickups:Stuart\Job:private] => Array
        (
            [0] => Stuart\Pickup Object
                (
                    [pickupAt:Stuart\Pickup:private] => 
                    [address:Stuart\Location:private] => 147 St John's Hill, SW11 1TQ, London, london, The United Kingdom, 147 St John's Hill, SW11 1TQ, London, The United Kingdom
                    [comment:Stuart\Location:private] => 
                    [phone:Stuart\Location:private] => 
                    [email:Stuart\Location:private] => 
                    [firstName:Stuart\Location:private] => Tristan
                    [lastName:Stuart\Location:private] => Allen
                    [company:Stuart\Location:private] => PowderKeg
                )

        )

    [dropOffs:Stuart\Job:private] => Array
        (
            [0] => Stuart\DropOff Object
                (
                    [packageType:Stuart\DropOff:private] => small
                    [packageDescription:Stuart\DropOff:private] => 
                    [clientReference:Stuart\DropOff:private] => 
                    [dropoffAt:Stuart\DropOff:private] => 
                    [address:Stuart\Location:private] => 135-137 Stephendale Rd, SW6 2PJ, London, london, The United Kingdom, 135-137 Stephendale Rd, SW6 2PJ, London, The United Kingdom
                    [comment:Stuart\Location:private] => 
                    [phone:Stuart\Location:private] => 
                    [email:Stuart\Location:private] => 
                    [firstName:Stuart\Location:private] => Tristen
                    [lastName:Stuart\Location:private] => Allen
                    [company:Stuart\Location:private] => The Sands End
                )

        )

    [deliveries:Stuart\Job:private] => Array
        (
            [0] => Stuart\Delivery Object
                (
                    [id:Stuart\Delivery:private] => 133153
                    [status:Stuart\Delivery:private] => pending
                    [trackingUrl:Stuart\Delivery:private] => https://stuart.sandbox.followmy.delivery/133153/c34fd19302cae8855d048fa4280b27e8
                    [origin:Stuart\Delivery:private] => Stuart\Pickup Object
                        (
                            [pickupAt:Stuart\Pickup:private] => 
                            [address:Stuart\Location:private] => 147 St John's Hill, SW11 1TQ, London, london, The United Kingdom, 147 St John's Hill, SW11 1TQ, London, The United Kingdom
                            [comment:Stuart\Location:private] => 
                            [phone:Stuart\Location:private] => 
                            [email:Stuart\Location:private] => 
                            [firstName:Stuart\Location:private] => Tristan
                            [lastName:Stuart\Location:private] => Allen
                            [company:Stuart\Location:private] => PowderKeg
                        )

                    [destination:Stuart\Delivery:private] => Stuart\DropOff Object
                        (
                            [packageType:Stuart\DropOff:private] => small
                            [packageDescription:Stuart\DropOff:private] => 
                            [clientReference:Stuart\DropOff:private] => 
                            [dropoffAt:Stuart\DropOff:private] => 
                            [address:Stuart\Location:private] => 135-137 Stephendale Rd, SW6 2PJ, London, london, The United Kingdom, 135-137 Stephendale Rd, SW6 2PJ, London, The United Kingdom
                            [comment:Stuart\Location:private] => 
                            [phone:Stuart\Location:private] => 
                            [email:Stuart\Location:private] => 
                            [firstName:Stuart\Location:private] => Tristen
                            [lastName:Stuart\Location:private] => Allen
                            [company:Stuart\Location:private] => The Sands End
                        )

                )

        )

    [distance:Stuart\Job:private] => 2.22
    [duration:Stuart\Job:private] => 8
    [pricing:Stuart\Job:private] => Stuart\Pricing Object
        (
            [priceTaxIncluded:Stuart\Pricing:private] => 6.3
            [priceTaxExcluded:Stuart\Pricing:private] => 5.25
        )

)

1 Like