Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty objects from readme example code #186

Open
Delindel-ML opened this issue Jul 22, 2019 · 14 comments
Open

Empty objects from readme example code #186

Delindel-ML opened this issue Jul 22, 2019 · 14 comments
Labels

Comments

@Delindel-ML
Copy link

Hey! This looks like an amazing package, however we are having a really hard time guessing around all the classes around and testing their usage.

The basic example at the readme does not work for us either, only returns a blank empty object.

Any advice?

Thanks!

@joe-pritchard
Copy link

I'd recommend using the official MWS docs (http://docs.developer.amazonservices.com/en_US/products/index.html) as your source of truth for how it all works. Pretty much every call you'll find there will have a corresponding class in this library, usually with an identical name, and you can find the parameters needed and response format in the MWS docs.

@Peardian
Copy link
Collaborator

Yes, the official MWS API documentation is the best way to learn about everything the API is capable of. The documentation in this library explains how to write use the classes in code and that's about it. It would be redundant for this library to explain the API itself or the underlying Amazon business processes when Amazon already has that information available.

As for the sample code, did you set up your configuration file first? If so, did you check the log messages generated by the request? That should give you all of the information you need.

@Delindel-ML
Copy link
Author

@joe-pritchard Thanks for responding! Yeah we are using it now, trying to find their counterparts in this library and test their usage as you suggested which seems like the logical path. We thought maybe there would be a documentation with more examples or something as other packages do, bu it does makes sense the way you put it.

@Peardian Indeed it is, we have tried some calls and we are getting an error like this in the example snippet:

[2019-07-22 17:29:16] local.INFO: Making request to Amazon: ListOrders  
[2019-07-22 17:29:17] local.ERROR: Bad Response! 400 Bad Request: MalformedInput - Start of list found where not expected  

Tried to change the credentials to no avail, and the MWS scratch pad works perfectly fine with it.

Is there maybe a dependency that got updated or something?

Thanks for everything!!

@Peardian
Copy link
Collaborator

Strange, I have never encountered that error before. The library only relies on PHP's cURL extension, and the sample code still works fine for me in PHP 7.2.19, so I am not sure what the problem could be. What version of PHP are you using?

It sounds like the error is related to the request parameters. You can see what parameters are set to by using the getOptions() method. (Note: be aware that this will also contain your secret credentials.) Try comparing these parameters to the ones set by the Amazon scratchpad and see if you notice any differences.

@Delindel-ML
Copy link
Author

Delindel-ML commented Jul 22, 2019

@Peardian I did try this, it does give an interesting amount of data out which i could compare and make sure it was correct.

I ran some more tests using the basic example, i started getting this "empty" response.

[
{},
{},
{},
{},
{},
{},
{}
]

Im assuming those are the orders, but somehow the bodies are not being correctly fetched.

I am using also this package: https://github.com/keithbrink/amazon-mws-laravel which gives a 400 error, with a totally empty object, however it claims to be a simple fork with laravel integration. By reading the libraries involved in this process it does seem to be verbatim to these, however the error persists.

The amount of anomalies makes me suspect something changed in their API responses, however it seems unlikely since i cant find any changes documented.

This, or we are not grasping something super essential about the package.

EDIT: We also suspect that maybe, we are missing some php extension that we cannot find listed anywhere?

As reference, we use the laravel homestead vagrant image.

EDIT2: I noticed that the "AmazonOrder" classes that are collected and ultimately output in the getList() method are filled with the correct information, but are not outputting anything, hence the empty objects by just copy pasting the code and running it.

If someone gets stuck in this very same problem (or confused integration) you simply have to use the "getData" method on each other to obtain an array that you can work with.

$orders = $amz->getList();
foreach ($orders as $order) {
    $data = $order->getData();
}

@Delindel-ML Delindel-ML changed the title A hard time finding documention for this! Empty objects from readme example code Jul 22, 2019
@Peardian
Copy link
Collaborator

I don't know what method you are using for getting output from the objects, nor do I have any experience with the Laravel fork, but it sounds like the code is working otherwise.

@Delindel-ML
Copy link
Author

Delindel-ML commented Jul 23, 2019 via email

@Dhavalptel
Copy link

Dhavalptel commented Aug 10, 2019

@Delindel I am also using this package: https://github.com/keithbrink/amazon-mws-laravel which gives a 400 error, with a totally empty object, I need to get amazon order list created in last 30 days.
Error log snippet

[2019-08-10 05:52:36] local.INFO: Making request to Amazon: ListOrders  
[2019-08-10 05:52:38] local.ERROR: Bad Response! 400 Bad Request: MalformedInput - Start of list found where not expected  
 public function getAmazonOrder(){
       $orderList = new AmazonOrderList("store1");
        $orderList->setLimits('Created','- 30 days');
        $orderList->setFulfillmentChannelFilter("MFN");
        $orderList->setOrderStatusFilter(array("Unshipped", "PartiallyShipped", "Canceled", "Unfulfillable"));
        $orderList->setUseToken();
        $orderList->fetchOrders();
        return $orderList->getList();
}

Can you please help how did you solve it? Is it working after changing credentials to no avail? How can I do that?

@Delindel-ML
Copy link
Author

Delindel-ML commented Aug 10, 2019 via email

@Dhavalptel
Copy link

Hey! @Delindel, Thanks for responding I'm also using Laravel and I checked the Laravel log it's this one

[2019-08-10 05:52:36] local.INFO: Making request to Amazon: ListOrders  
[2019-08-10 05:52:38] local.ERROR: Bad Response! 400 Bad Request: MalformedInput - Start of list found where not expected  

I'm confused because my credentials working fine for AmazonProductInfo but it doesn't work for AmazonOrderList.
I've got these credentials

'store1' => [
		'merchantId'       => env('mwsMerchantId'),
		'marketplaceId'    => env('mwsMarketplaceId'),
		'keyId'            => env('mwsKeyId'),
		'secretKey'        => env('mwsSecretKey'),
		'mwsAuthToken'     => env('mwsAuthToken'),
		'amazonServiceUrl' => env('mwsAmazonServiceUrl'),
		'muteLog'          => env('mwsMuteLog', false),
],

Does that method requires additional credentials?
Thanks!

@Delindel-ML
Copy link
Author

Delindel-ML commented Aug 11, 2019 via email

@Dhavalptel
Copy link

Hi @Delindel This package https://github.com/sonnenglas/amazon-mws-laravel works great with the same method
Thanks!

@Delindel-ML
Copy link
Author

Delindel-ML commented Aug 12, 2019 via email

@keithbrink
Copy link

keithbrink commented May 7, 2020

Found this issue while researching a fix...y'all should have opened an issue!

Anyways, this is fixed in my fork now (version 7.1.0), turns out you can't have the root marketplaceId AND the marketplaceId.Id.1 parameter set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants