Open Kernel1453 opened 1 year ago
Hi All, Do you know any solution to overcome this, we are still trying this. @jlevers
@Kernel1453 what is the full response you get when you call createUploadDestinationForResource
?
Closing due to inactivity. If you still need support on this, let me know and I'll reopen it.
Hello, still cant overcome this and need support.
Please answer my previous question so that I can help you:
@Kernel1453 what is the full response you get when you call
createUploadDestinationForResource
?
@jlevers Return message is same.
[400] { "errors": [ { "code": "InvalidInput", "message": "Attachment with ID XXXXXX does not exist", "details": "" } ] }
So the error is happening before you get to the sendInvoice
call? Have you ever reached that call?
@jlevers No, never. I always Got same error in same point.
What does your $destination
variable contain if you var_dump
it right before the createUploadDestinationForResource
call?
@jlevers Hi, thank you for reply my message. this is my var_dump => string(56) "messaging/v1/orders/406-1310933-XXXXXXX/messages/invoice"
and when i send file returns
{ "message": "Client error: `POST https://sellingpartnerapi-eu.amazon.com/messaging/v1/orders/406-1310933-XXXXXXX/messages/invoice?marketplaceIds=A33AVAJ2PDY3EV` resulted in a `400 Bad Request` response:\n{\n \"errors\": [\n {\n \"code\": \"InvalidInput\",\n \"message\": \"Attachment with ID 083a7d5a-b617-4473-b03c-2d52cb1 (truncated...)\n", "exception": "GuzzleHttp\\Exception\\ClientException", "file":
here error is Attachment with ID doesnt exist.
Could you please check my code below about MD5 hashing and other methods are correct or need to be fixed? again thank you very much.
if ($request->hasFile($fileName)) {
$uploadApi = new UploadsV20201101Api($config);
$fileContents = $request->file($fileName)->get();
$md5Content = md5($fileContents,true);
$destination = 'messaging/v1/orders/' . $amazonOrderId . '/messages/' . $messageType ?? $request->mesage_type;
$result = $uploadApi->createUploadDestinationForResource($marketplaceIds, $md5Content, $destination);
$resultPayload = $result->getPayload();
$url = $resultPayload->getUrl();
$headers = $resultPayload->getHeaders();
$headers['Content-MD5'] = base64_encode(md5($fileContents,true));
$headers['Content-Type'] = 'Binary';
$filename = $messageType . $amazonOrderId . '.' . $request->file($fileName)->extension();
$response = Http::attach(
'attachment', $fileContents, $filename,$headers
)->withHeaders($headers)->put($url);
// dd($response->getBody()->getContents());
$attachment = new Attachment([
'upload_destination_id' => $resultPayload['upload_destination_id'],
'file_name' => $filename
]);
// dd($attachment);
return [$attachment];
}
best regards
We still have this issue. Now getting yoursignature doesnt match. What should we do? Please help @jlevers
I'm not positive about this, but I think you need a leading slash in your $destination
string (so /messaging/v1/orders/406-1310933-XXXXXXX/messages/invoice
instead of messaging/v1/orders/406-1310933-XXXXXXX/messages/invoice
).
If that doesn't solve the problem, I recommend contacting Amazon support – I don't use this API so it's hard for me to know what the issue is.
hi @jlevers when i use /messaging, at this time i get
"message": "[403] {\n \"errors\": [\n {\n \"code\": \"Unauthorized\",\n \"message\": \"Access to requested resource is denied.\",\n \"details\": \"\"\n }\n ]\n}", "exception": "SellingPartnerApi\ApiException",
Do you have the Buyer Communication role?
@jlevers yes, i have all the roles including the buyer communication role. I can use createUnexpectedProblem and can get all orders & updates.
Weird, ok. I recommend opening a support case with Amazon, because I don't have any further insight into this, and I'm 99% sure it's an API issue, not an issue with this library.
@jlevers thank you very much. I will open a case and inform you.
Dear All, I'm trying to upload invoice but I'm getting error below
What I'm trying to do is
where i am making mistake, could you please help asap? Thank you. Best Regards