Call getUserTransactions - yodlee

I'm using the Yodlee REST API and trying to call getUserTransactions.
In the request documentation, it says that only three params are required and the rest aren't. However, it seems not to work without the extra two params.
When sending with only the following:
cobSessionToken
userSessionToken
searchFetchRequest.searchIdentifier.identifier
I get the following error:
{
errorOccurred: "true"
exceptionType: "com.yodlee.core.IllegalArgumentValueException"
referenceCode: "_ad0299a4-7445-46ae-bf29-9596974af4b6"
message: "Invalid argument value: Search Result Range of TransactionSearchFetchRequest cannot be NULL"
}
It works when adding the following params
searchFetchRequest.searchResultRange.startNumber
searchFetchRequest.searchResultRange.endNumber

You need to pass on those parameters also. As those parameters will be used to paginate the transactions if those are very high in numbers.
For e.g. if the response is having
Number of hits = 1300 (From executeUserSearchRequest API)
then call getUserTransactions in loop with
1st call
StartNumber = 1
EndNumber = 500
2nd call
StartNumber = 501
EndNumber = 1000
3rd call
StartNumber = 1001
EndNumber = 1300
Meanwhile we'll get that corrected over the portal that those fields are mandatory.

Related

Office 365 REST API /$count filter giving wrong data

I'm trying to get count of records for different objects. The response of /$count filtered APIs is inconsistently giving wrong response.
I am referring this documentation link for usage instructions.
Request URL: GET https://outlook.office.com/api/v2.0/me/Events/$count
Response: -1
To verify if the above mentioned response is legitimate, I tried to get all events with a skip filter to identify the actual number of records present.
After a certain attempts following request URL gave me final count:
Request URL: GET https://outlook.office.com/api/v2.0/me/events/?$skip=159
Response:
{
"#odata.context": "https://outlook.office.com/api/v2.0/$metadata#Me/Events",
"value": [
{
"Id": "AAMkADMzYzIxNTBjLWUyMWUtNDgzYi04NTEwLTc5YTkzMWI5MmE4MgBGAAAAAABjOnbtK9ZkTIjwInd5bfYcBwDe_ScfFfAUQaKHRwnzV1lBAAAAAAENAADe_ScfFfAUQaKHRwnzV1lBAACs2ojfAAA=",
"CreatedDateTime": "2016-11-28T11:09:03.8359488Z",
"LastModifiedDateTime": "2017-02-21T08:04:48.8262751Z"
}
]
}
This implies that after skipping 159 records, I've 160th record present in the authenticated account but $count filtered API doesn't give me a valid response.
I tried testing this scenario with two different accounts where I noticed this anomaly for /message API as well. The HTTP GET call to messages/$count gives me 1563 whereas after trying with skip filter I found the total count to be 1396
I want to know if $count returns a legitimate response? If yes then explain this anomaly If no then is there any pattern where we should expect response to inconsistent?
To get a count of the number of events, you need to specify start time and end time. Here is what I use:
https://outlook.office.com/api/v2.0/me/calendarview/$count?startDateTime=2017-05-01T00:00:00Z&endDateTime=2017-05-31T23:59:59Z
If you don't specify the dates, you will get 400 with the following error message:
{"error":{"code":"ErrorInvalidParameter","message":"This request requires a time window specified by the query string parameters StartDateTime and EndDateTime."}}

I am trying to use Yodlee/executeUserSearchRequest as a RESTful request and need an answer on how to call

I am working with the Yodlee services in c# and using the RESTful api. So far I have successfully connected and logged in with my CobrandSession and UserSessionToken in the development environment. I used the sample apps provided in c# and with some advice from shreyans i got an app working. What I got working was
1) Get YodleeAuthentication
2) Get UserAuthentication
3) Get ItemSummaries
I am now trying to get the full transaction details for each of the Items (i.e. collections of accounts that are an Item)
reading the Docs here https://developer.yodlee.com/Indy_FinApp/Aggregation_Services_Guide/REST_API_Reference/executeUserSearchRequest it states that I need to call executeUserSearchRequest and then paginate through the results using the getUserTransactions. So I am stuck at this point. I dont really want a search which has parameters I just want ALL transactions for this account that I can see.
However, I am using the variables as defined in that page :-
var request = new RestRequest("/jsonsdk/TransactionSearchService/executeUserSearchRequest", Method.POST);
request.AddParameter("cobSessionToken", param.CobSessionToken);
request.AddParameter("userSessionToken", param.UserSessionToken);
request.AddParameter("transactionSearchRequest.containerType", param.ContainerType);
request.AddParameter("transactionSearchRequest.higherFetchLimit", param.HigherFetchLimit);
request.AddParameter("transactionSearchRequest.lowerFetchLimit", param.LowerFetchLimit);
request.AddParameter("transactionSearchRequest.resultRange.endNumber", param.EndNumber);
request.AddParameter("transactionSearchRequest.resultRange.startNumber", param.StartNumber);
request.AddParameter("transactionSearchRequest.searchFilter.currencyCode", param.CurrencyCode);
request.AddParameter("transactionSearchRequest.searchFilter.postDateRange.fromDate", param.FromDate);
request.AddParameter("transactionSearchRequest.searchFilter.postDateRange.toDate", param.ToDate);
request.AddParameter("transactionSearchRequest.searchFilter.transactionSplitType.splitType", param.SplitType);
request.AddParameter("transactionSearchRequest.ignoreUserInput", param.IgnoreUserInput);
request.AddParameter("transactionSearchRequest.searchFilter.itemAcctId", param.ItemAcctId);
var response = RestClientUtil.GetBase().Execute(request);
var content = response.Content;
return new YodleeServiceResultDto(content);
As per the response from shreyans in this posting Getting Error "Any one of [**] of transactionSearchFilter cannot be NULL OR Invalid Values I am not putting in the ClientId and the ClientName
The documentation doesn't specify the format of the dates but the example seems to tell me that its american date format. And specifies a parameter saying IgnoreUserinput, but doesnt have a parameter for user input so this is confusing
When I make a call using this format I get an error response
var getSearchResult = yodleeExecuteUserSearchRequest.Go(yodleeExecuteUserSearchRequestDto);
getSearchResult.Result="
{"errorOccured":"true","exceptionType":"Exception Occured","refrenceCode":"_60ecb1d7-a4c4-4914-b3cd-49182518ca5d"}"
But I get no error message in this and I have no idea what I have done wrong or where to look up this error, can somebody who has used Yodlee REST Api point me in the right direction as I need to get this researched quickly....
thanks your your help, advice, corrections and pointers....
Here is the list of parameters which you can try
1) For a specific ItemAccountId all transactions
transactionSearchRequest.containerType=all
transactionSearchRequest.higherFetchLimit=500
transactionSearchRequest.lowerFetchLimit=1
transactionSearchRequest.resultRange.startNumber=1
transactionSearchRequest.resultRange.endNumber=500
transactionSearchRequest.searchClients.clientId=1
transactionSearchRequest.searchClients.clientName=DataSearchService
transactionSearchRequest.searchFilter.currencyCode=USD
transactionSearchRequest.searchClients=DEFAULT_SERVICE_CLIENT
transactionSearchRequest.ignoreUserInput=true
transactionSearchRequest.ignoreManualTransactions=false
transactionSearchRequest.searchFilter.transactionSplitType=ALL_TRANSACTION
transactionSearchRequest.searchFilter.itemAccountId.identifier=10000353
2) For a Specific account (itemAccountId) with start and end dates
transactionSearchRequest.containerType=all
transactionSearchRequest.higherFetchLimit=500
transactionSearchRequest.lowerFetchLimit=1
transactionSearchRequest.resultRange.startNumber=1
transactionSearchRequest.resultRange.endNumber=500
transactionSearchRequest.searchClients.clientId=1
transactionSearchRequest.searchClients.clientName=DataSearchService
transactionSearchRequest.searchFilter.currencyCode=USD
transactionSearchRequest.searchClients=DEFAULT_SERVICE_CLIENT
transactionSearchRequest.ignoreUserInput=true
transactionSearchRequest.ignoreManualTransactions=false
transactionSearchRequest.searchFilter.transactionSplitType=ALL_TRANSACTION
transactionSearchRequest.searchFilter.itemAccountId.identifier=10000353
transactionSearchRequest.searchFilter.postDateRange.fromDate=08-01-2013
transactionSearchRequest.searchFilter.postDateRange.toDate=10-31-2013

Why does Stripe.com return error (402) Payment Required?

I'm not seeing this particular error described in stripes API anywhere. Anyone know what's going on?
Here is my VB.net code to create a customer:
Function CreateStripeCustomer(ByVal Token As String) As String
'' The Stripe Account API Token - change this for testing
Dim STR_Stripe_API_Token As String = "sk_test_SECRET_TEST_KEY" '<-- test secret key. Change to live later.
''The Stripe API URL
Dim STR_Stripe_API_URL As String = "https://api.stripe.com/v1/customers"
''Creates a Web Client
Dim OBJ_Webclient As New System.Net.WebClient()
''Creates Credentials
Dim OBJ_Credentials As New System.Net.NetworkCredential(STR_Stripe_API_Token, "MY_STRIPE.COM_PASSWORD")
''Sets the Credentials on the Web Client
OBJ_Webclient.Credentials = OBJ_Credentials
''Creates a Transaction with Data that Will be Sent to Stripe
Dim OBJ_Transaction As New System.Collections.Specialized.NameValueCollection()
OBJ_Transaction.Add("email", "PERFECTLY_VALID_EMAIL")
OBJ_Transaction.Add("card", "PERFECTLY VALID TOKEN RETURNED BY STRIPE.JS")
''The Stripe Response String
Dim STR_Response As String = Encoding.ASCII.GetString(OBJ_Webclient.UploadValues(STR_Stripe_API_URL, OBJ_Transaction))
Return STR_Response
End Function
The 402 "payment required" error is happening on the line:
Dim STR_Response As String = Encoding.ASCII.GetString(OBJ_Webclient.UploadValues(STR_Stripe_API_URL, OBJ_Transaction))
If you're seeing this in live, it's also possible the card number is simply incorrect, eg: if you inspect the body of the 402 response:
Well, I switched to my "LIVE" keys instead of my "TEST" keys, and that fixed it. Just wasted 3 hours of my life trying to fix this. Hope this helps somebody else.
The more correct answer is that you need to use the appropriate test card numbers. See https://stripe.com/docs/testing
Stripe provides a test environment in which you use the test publishable/secret keys, as oppose to waiting till production. However, what seems like the down side, which is in fact very helpful is that you need to comply to Stripe's testing conditions and use their given card numbers and inputs to test different aspects of your api call.
For example, in order to receive certain errors you can input these numbers:
card_declined: Use this special card number - 4000000000000002.
incorrect_number: Use a number that fails the Luhn check, e.g. 4242424242424241.
invalid_expiry_month: Use an invalid month e.g. 13.
invalid_expiry_year: Use a year in the past e.g. 1970.
invalid_cvc: Use a two digit number e.g. 99.
For more information refer to the link that Samir posted.
For iOS
If you are following tutorial from Ray Wunderlich website the reason why error may appear is that you run your test back end (web.rb file) and after that add you TEST_SECRET_KEY.
Go to the terminal click control+C, make sure you have already added your TEST_SECRET_KEY, save file and do ruby web.rb.
For now, everything should work fine.
For reference, I used this number of the card for testing: 4242 4242 4242 4242

Rails koala "error unsupported get request" after long task - calling FB graph API

After a long task (14s and can be more with more than 600 call to Facebook) my app returns a 500 internal server error with the following description:
Koala::Facebook::APIError (GraphMethodException: Unsupported get request.)
What I do is something like this:
#FBGraph = Koala::Facebook::API.new
tud = MyUsers.all
tud.each do |user|
graph = #FBGraph.get_object(user.fb_user_id)
picture = #FBGraph.get_picture(user.fb_user_id)
thisTud = MyUsers.find(user.id)
thisTud.name = graph["name"]
thisTud.url = graph["link"]
thisTud.url_pic = picture
if thisTud.save
puts "Saved!"
else
puts "Error"
end
end
I receive (on the terminal) all the "Saved!", but after retrieving the data, it does automatically the mysql operations and it fails. And the data is not saved on the DB.
As suggested in this post I have placed the #FBGraph = Koala::Facebook::API.new in a new Thread, but nothing changes.
Note: when I'd do the same operations with less users, all was working good.
How hellvinz says is a facebook bug.
I have find a workaround for now that seems that works:
change this
graph = #FBGraph.get_object(user.fb_user_id)
to this
graph = #FBGraph.get_object("#{user.fb_user_id}?fields=id,name,username,picture,link")
Explicitly declaring the fields seems that solve the problem.
And if this is not sufficient there are 2 more tricks that can resolve the problem:
Calling again after a time delay (for example after an hour), and calling only the requests incomplete
Creating multiple fb app ID and accounts differentiating the requests with the accounts

Can not update the Variant Price using the ShopifyAPI

I am facing a problem - can not update the price of the variant using the ShopifyAPI..
while updating the price of the variant, it is giving the error
#remote_errors=#<\ActiveResource::ResourceInvalid: Failed. Response code = 422. Response message = Unprocessable Entity.>, #validation_context=nil, #errors=#<\ActiveResource::Errors:0x000000029eb1d0 ...>>, #messages={:base=>["Options are not unique"]}
'\' after '<' is required to show the error, otherwise stack overflow is hiding the error.
as required on another question
on production store, the request id is "38f5c3b3b7bdf4433724a845c6df4571"
on test store, the request id is "6050f165586b631e81b840dc0e1e6807"
More Findings
variant price change on test store
p = ShopifyAPI::Product.last
v = p.variants.first
v.price = "8.00"
v.save
initial price of variant = "9.00"
returns false, with error #messages={:base=>["Options are not unique"]}
request id 978ad18483f40ff3946df18df0a9d1d8
.
.
variant price change on live store
p = ShopifyAPI::Product.first
p.variants[0].price = "24.65"
p.save
initial price of variant = "25.65"
return true, but price is not changed
request id a9a798b631e3dd10fc81b723f2883af1
.
.
variant price change through product on test store
p = ShopifyAPI::Product.first
p.variants[0].price = "8.00"
p.save
initial price of variant = "7.00"
return true and price is updated
request id 7d995f6f6ed3bf515e69a1640f27f44a
.
.
variant price change through product on live store
p = ShopifyAPI::Product.last
v = p.variants.first
v.price = "4.00"
v.save
initial price of variant = "3.00"
returns false, with error #messages={:base=>["Options are not unique"]}
request id c6aaa5b65576eb4ec0d89715d25b787e
#messages={:base=>["Options are not unique"]}
That's your problem. Looking at the logs you're using POST to submit the request, which is used for creating new objects. Shopify is recognizing that there's already a variant with the specified options and refusing to create a new one.
If you use PUT as your HTTP method instead, Shopify will correctly interpret this as an update and everything should be fine.
This is a bug in ActiveResource 3.1+.
I have opened an ActiveResource pull request, but I am still awaiting a response at the moment.
I have committed a workaround for this bug in shopify_api v3.0.1, so upgrading this gem will fix this issue for you issue.