Rails koala "error unsupported get request" after long task - calling FB graph API - ruby-on-rails-3

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

Related

ggmap error: HTTP 400 Bad Request The Google Maps Platform server rejected your request. The provided API key is invalid

I am trying to retrieve a ggmap background map using get_map() in R but I keep getting an error message "HTTP 400 Bad Request The Google Maps Platform server rejected your request. The provided API key is invalid.".
Examples:
BA <- get_map("Buenos Aires, Argentina", source = "stamen", maptype = "toner-lite", zoom = 11)
spainmap<- ggmap(get_googlemap(center = c(lon = -3.703790, lat = 40.416775), zoom = 10, maptype = 'terrain', color = 'color'))
I know that every user must have a valid google API key, I´ve created a billing account and my key is definitely valid. I´ve also enabled all the APIs, including Geocoding, Geolocation, Maps Embed and Maps Static since others suggested this.
I´ve reinstalled the latest version of R and Rstudio, restarted R session multiple times but nothing seems to work.
According to this website https://developers.google.com/maps/documentation/maps-static/error-messages I´m getting the error because some required parameter is either missing or is invalid, but I really don´t think that´s the case since I´ve tried to get maps in different locations and using various ggmap functions but nothing works.
How do I fix this? Has anyone else had this problem?

Expiring api request caches

I've implemented API caching based on http://robots.thoughtbot.com/caching-api-requests. I'm using memory as the storage. How can I reset the cache manually without restarting the server?
I've tried using Rails.cache.clear, but it doesn't seem to work. The data is still getting pulled from the cache. I checked it by observing the server log for my puts message (as shown below).
Caching code:
module Meh
class Api
include HTTParty
#...
cache_name = options[:path] + "/" + options[:params].values.join(",")
response = nil
APICache.get(cache_name, cache: 3600) do
response = self.class.get options[:path], query: options[:params]
# For future debugging
puts "[API] Request: #{response.request.last_uri.to_s}"
# Just return nil if there's an error with the request, for now
if response.code == 200
response.reverse!
else
response = nil
end
end
end
Have you tried 'rake tmp:cache:clear' or deleting the contents of tmp/cache/ manually?
Are you trying to delete the contents of the cache from within the code?
Reading through the api_cache gem, it looks like this is a memory cache, not a file cache. Which would be consistent with your reports. It also looks like there is a .delete method on the APICache api. link So APICache.delete(cache_name) may be what you are looking for.

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

400 Bad Request error when using .net Paymill Wrapper

I'm trying to use the .net Paymill Wrapper
When trying to add a subscription, I'm getting back a 400 Bad Request.
To illustrate the problem, I created a branch and changed the Sandbox console app to call the method to test addSubscription
The problem is happening here where the request is actually posted.
The content posted is: (as an example)
client=client_bbe895116de80b6141fd&
offer=offer_32008ddd39954e71ed48&
payment=pay_81ec02206e9b9c587513
It appears this hasn't been updated for sometime, and the original author is unresponsive via email or twitter, so I've forked the repo and am trying to fix the error.
I had a look at your code and found out that you are not creating the offer object correctly.
In your addSubscription method (SandboxConsole project), i found this code snippet
Subscription subscription = new Subscription();
subscription.Client = new Client() { Id = "client_bbe895116de80b6141fd" };
subscription.Offer = new Offer() { Id = "offer_32008ddd39954e71ed48" };
subscription.Payment = new Payment() { Id = "pay_81ec02206e9b9c587513" };
Offer object should be initialized with parameters like amount, currency, interval.
Since the offer object doesn't exist, assigning a subscription to it fails, giving you bad request error.

Negative Testing for PayPal using Sandbox with VB.NET - how to simulate different scenarios?

I have a website written in VB.NET that implements PayPal for payments. This is all working fine for successful payments, but I need to be able to simulate scenarios of a failed transaction, pending transaction, etc.
I have read the documentation, which starts on page 47. I enabled Negative Testing in a business account that I created in a Sandbox, but I am not getting desired results.
To simulate an error, as specified in the documentation, I'm passing an error code to Token, which is then used in a request to DoExpressCheckoutPayment - code below - but instead of this raising the error 10417, the response says Invalid Token:
Dim oldToken As String
With RequestDetails
oldToken = .Token
.Token = "10417"
End With
Dim request As New DoExpressCheckoutPaymentRequestType
request.DoExpressCheckoutPaymentRequestDetails = RequestDetails
Dim response As DoExpressCheckoutPaymentResponseType
response = DirectCast(caller.Call("DoExpressCheckoutPayment", request),
DoExpressCheckoutPaymentResponseType)
Questions:
What am I doing wrong in the code above so that I can't trigger a correct error?
How do I simulate a response where the status is Pending, Processed, Failed, etc.?
I was testing this about a week ago and was receiving the same problem, now, I no longer receive an error:
API Request:
METHOD=DoExpressCheckoutPayment
VERSION=82
token=10755
PayerID=GNT5WLV6WKLYW
PAYMENTACTION=Sale
AMT=456
PAYMENTREQUEST_0_AMT=458
PAYMENTREQUEST_0_ITEMAMT=458.00
PAYMENTREQUEST_0_SHIPPINGAMT=20.00
PAYMENTREQUEST_0_TAXAMT=46.20
PAYMENTREQUEST_0_CURRENCYCODE=USD
PAYMENTREQUEST_0_DESC=test EC payment
L_PAYMENTREQUEST_0_NAME0=Books
L_PAYMENTREQUEST_0_AMT0=154.00
L_PAYMENTREQUEST_0_NUMBER0=ABC123
L_PAYMENTREQUEST_0_QTY0=2
L_PAYMENTREQUEST_0_NAME1=CDs
L_PAYMENTREQUEST_0_AMT1=50.00
L_PAYMENTREQUEST_0_NUMBER1=BY-Z4736
L_PAYMENTREQUEST_0_QTY1=3
API Response:
TIMESTAMP=2011-09-27T20:39:57Z
CORRELATIONID=13126abeb4615
ACK=Failure
VERSION=82
BUILD=2133933
L_ERRORCODE0=10755
L_SHORTMESSAGE0=Unsupported Currency.
L_LONGMESSAGE0=Currency is not supported
L_SEVERITYCODE0=Error
I did find an article on x.com that deals with this issue as well.