mirakl / sdk-php-shop

Mirakl PHP SDK for sellers
30 stars 16 forks source link

OR13 Bad Request #63

Closed egalindoEH closed 6 months ago

egalindoEH commented 7 months ago

Hi, Im having a lot of issues with OR13 endpoint.

$request = new ExportOrdersAsyncSubmitRequest();
$request->setStartUpdateDate(new \DateTime('2023-01-01T00:00'));
$request->setEndUpdateDate(new \DateTime('2024-03-19T00:00')); //Actually Im trying to use current day but is the same issue
$result = $api->exportOrdersAsync($request);

But after this gave me an exception: 400 Bad Request response

Sometimes works but most common isn't. I tried changing timezone but is the same.

Im using: PHP: ("php": "^8.0") Mirakl: "mirakl/sdk-php-shop": "^1.20"

egalindoEH commented 7 months ago

Debugging sdk, I saw that sometimes async is false and others is true.

Why is happening this?

Async equals false image

Async equals true image

amarie75 commented 7 months ago

Hello,

You have an exception: 400 Bad Request response because the interval between the start date and the end date can't be greater than a year. This information is mentioned in the response body

try {
    $result = $api->exportOrdersAsync($request);
} catch (\GuzzleHttp\Exception\ClientException $e) {
    throw new \Exception($e->getResponse()->getBody()->getContents());
}

Best regards, Alexandre