GetMatchingProductSample AMAZON API - api

Im try to Get Product details with GetMatchingProductSample.php
request param look correctly:
$request->setSellerId(MERCHANT_ID);
$request->setMarketplaceId(my ID);
$request->setASINList(my ASIN);
when i try to execute i receve always this error:
Fatal error: Call to a member function _toQueryParameterArray() on a non-object
I've look a method but i dont see any error
When i type request-> i have only these methods:
setASINlist
setSellerId
setMWSAuthToken

Finally i found a way to do a right call.
Obviously they lacked the parameters and if someone can serve this is the correct call:
$asins = array('B06Y16RL4W', 'B071DQ128D');
$request = new
MarketplaceWebServiceProducts_Model_GetMatchingProductRequest();
$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$request->setSellerId(MERCHANT_ID);
$request->setMarketplaceId(MARKETPLACE_ID);
$asin_list->setASIN($asins);
$request->setASINList($asin_list);

Related

Getting data from AlamofireNetworkClient request

From the documentation
let client = AlamofireNetworkClient()
let request = client.request(method: .get, endpoint: "http://my-amazing-api.com/endpoint")
let data = request.asData // parse `Data`
First line fails to compile: Missing argument for parameter 'eventMonitors' in call
Second line fails to compile: Cannot infer contextual base in reference to member 'get'
If I change the client to
let client: AlamofireNetworkClient = .default
I can at least compile, but how do I get actual data back from the call?
'data' is PovioKitPromise.Promise<Foundation.Data>
How to I get the result of the call as actual data/ascii/whatever?
There is not a single functioning example in the documentation of extracting a response from a request.

How to I get the detail (custom error message) returned with a bad request status code? So that I can do an ASSERT on it

Hi so I am setting up some Integration tests (using Xunit) and I would like to run an Assert to check whether the correct custom error message is returned.
This is the data I need to get is in the following response see image...
detail: "Username must be unique" Don't worry this message will be modified to be more useful later on I am just wanting to get it working first
Required Info
This is the current code...
//Act
response = await _httpClient.PostAsync("CompleteUserSetup", formContent);
//Assert
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode) ; //Bad request should be returned
//TODO: check custom error message is correct
So hoping for...
ASSERT.Equal("Username must be unique", some code to get detail from response)
Okay so I figured out how to get the data I needed. I just needed to convert the result into an object and then I was able to pull the detail data that I needed.
var resultModel = await System.Text.Json.JsonSerializer.DeserializeAsync<Result>(response.Content.ReadAsStream(), JsonSerializerHelper.DefaultDeserialisationOptions);
var errorMessage = resultModel.detail;

Unable to get card details for connected account in Stripe

I am trying to retrieve card details for connected accounts customer, As per stripe documentation we need to pass stripe_account parameter in each api call to work with connected accounts. However in case of retrieving card details it is throwing error for the stripe_account parameter.
Following is how my api call looks like:
\Stripe\Customer::retrieveSource(
'cus_GqzjjKIQXO1JgB',
'card_1GJHkSEyjL72dRjPECxaHlEF',["stripe_account" =>'xxxxxxxxx']
);
Following is the error:
Received unknown parameter: stripe_account
Can someone please help with this.
Thanks
This occurs because of the signature of the retrieveSource method:
public static function retrieveSource($id, $sourceId, $params = null, $opts = null)
In this case the stripe_account is being passed as a param instead of an opt.
You can fix this by passing an empty array for params:
<?php
\Stripe\Stripe::setApiKey('sk_test_xxx');
$ss = \Stripe\Customer::retrieveSource(
'cus_xxx',
'card_xxx',
[],
["stripe_account" => 'acct_xxx']
);
?>
Hope that helps!
v3nkman

Call to a member function parameter() on a non-object in Lumen API

I got this error in my Lumen API update user module. I didn't get the Request $request values from postman. It's happening only in my UserController,
my other controllers work fine. I'm using the put method to update the user.
This is the error:
FatalErrorException in Request.php line 901: Call to a member function
parameter() on a non-object in Lumen API
My update function looks like this:
public function updateUser(Request $request,$user_id)
{
try {
$user = User::findOrFail($user_id);
} catch(ModelNotFoundException $e) {
return "User not found";
}
$user->buyer_id = $request->buyer_id;
The thing is, Lumen and Laravel use different route resolvers. You can see it for yourself if you just output the type of the variable $route just before that line 901.
Try $request['buyer_id'] instead.
I would suggest to use $request->input('buyer_id'); instead which would not throw any error if the buyer_id doesn't exist on $request stack (if it helps).
We can also pass the default value like this:
$request->input('buyer_id', null);

request.setAttribute is not working with chain.doFilter

I have two servlet ReplayFilter and VideoReplayServlet. From ReplayFilter, I am calling VideoReplayServlet using chain.doFilter. I am able to call VideoReplayServlet from ReplayFilter but I am not able to get userId variable from request object in VideoReplayServlet, which I have already set in request object before calling chain.doFilter. You can find my code below -
In ReplayFilter -
request.setAttribute("userId", userId);
request.setAttribute("uname", "mari");
chain.doFilter(request, response);
In VideoReplayServlet -
String uname = request.getParameter("uname");
String user_Id = request.getParameter("userId");
In VideoReplayServlet replay, I am getting both uname and user_Id null.
Can anybody help me?
I think the issue here is that you are setting it as an attribute and expecting it as a parameter which is contradicting.
Try the below code instead
request.getAttribute("userId", userId); //Note the getAttribute() instead of getParameter()