Comments (8)
This allows access to the headers of the request that caused the error:
begin
ad_account = FacebookAds::AdAccount.get("act_#{ad_account_id}", 'name')
puts "Ad Account Name: #{ad_account.name}"
rescue FacebookAds::APIError => e
puts e.instance_variable_get(:@api_response).headers
end
produces this:
{"access-control-allow-origin"=>"*", "strict-transport-security"=>"max-age=15552000; preload", "x-fb-trace-id"=>"XXXXXX", "content-type"=>"application/json; charset=UTF-8", "x-fb-rev"=>"4116048", "x-app-usage"=>"{\"call_count\":0,\"total_cputime\":0,\"total_time\":0}", "cache-control"=>"no-store", "pragma"=>"no-cache", "expires"=>"Sat, 01 Jan 2000 00:00:00 GMT", "www-authenticate"=>"OAuth \"Facebook Platform\" \"invalid_token\" \"Invalid OAuth access token.\"", "x-fb-debug"=>"XXXXX", "date"=>"Wed, 18 Jul 2018 22:22:19 GMT", "connection"=>"close", "content-length"=>"113"}
from facebook-ruby-business-sdk.
Check the last_api_response
of the ad object you are using. You can access the headers from there. See #50 (comment) for an example.
from facebook-ruby-business-sdk.
Joe thanks a lot. I'm also trying to handle an ad account being limited or app being limited and catching it with a begin -> rescue but the last_api_response can't be found in the rescue. Maybe I should just make sure it never happens as opposed to trying to handle when it does
from facebook-ruby-business-sdk.
I'm already performing some sort of "ping" to the ad account before performing anything so I might be good but you can never be too safe.
There's always the scenario that when you ping the adaccount everything is fine but halfway through processing they reach their limit you know
from facebook-ruby-business-sdk.
That helps tremendously thank you so much Joe!
One last question. Do you know if there's an option to not allow users to edit campaigns made through the API in their ads managers? Or is that impossible.
from facebook-ruby-business-sdk.
You are welcome! Unfortunately, I don't know if there is a way to block users from editing API created campaigns with Ads Manager. Sorry!
from facebook-ruby-business-sdk.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
from facebook-ruby-business-sdk.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
from facebook-ruby-business-sdk.
Related Issues (20)
- Ruby 3.1.0 errors with Psych::DisallowedClass: Tried to load unspecified class: Time HOT 2
- Can we upgrade safely? HOT 1
- When successful in creating a custom conversion, the response body is incorrect and generates a JSON::ParserError
- Not being able to retrieve preview code
- `ad_account.adrules_library.first.evaluation_spec` raises JSON::ParserError
- Update Faraday dependency to 2.x HOT 2
- Can't pull campaigns from Ad Accounts HOT 1
- File.exists? method was removed in ruby 3.2
- undefined method `configure' for FacebookAds:Module (NoMethodError) HOT 1
- Custom Properties Feature is not supported for Server-Side API in Ruby SDK HOT 1
- Support for app_data field HOT 5
- Specs are not passing
- Uninitialized constant FacebookAds (NameError)
- Cannot add user to custom audience on Ruby 3.2
- facebookbusiness README says that Ruby v2 is sufficient but the gemspec says otherwise HOT 1
- Breakdown fields are missing on AdsInsights
- `::UploadIO` is deprecated HOT 1
- JSON parsing fails in Rails 7.1 apps
- Graph API V12.0 Deprecation HOT 1
- Unsupported targeting option: targeting_automation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facebook-ruby-business-sdk.