We have the following error indicating the we try to parse something that is not parseable:
JSON::ParserError: 859: unexpected token at 'Sorry, this content isn't available right now'
from /Users/mathieu/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.6.1/lib/json/common.rb:216:in `parse'
Doing some research, it comes from the fact that we try to parse the response body which is equal to 'Sorry, this content isn't available right now', this causes a JSON::ParserError.
module FacebookAds
class APIResponse
attr_reader :status_code, :headers, :body
def initialize(status_code, headers, body)
@status_code = status_code
@headers = headers
@body = body
end
def result
is_json_response? ? **JSON.parse(body)** : body
end
...
end
end
Expected Results:
It should:
Be able to handle a response body of type 'Sorry, this content isn't available right now' and not cause a JSON::ParserError
Sends us back the id of the custom conversion created
Which SDK version are you using?
0.12.0.1
What's the issue?
When successful in creating a custom conversion through the API, the response body is incorrect and generates a JSON::ParserError.
Steps/Sample code to reproduce the issue
First we generate a hash called
facebook_attributes
that we will use as params for our API call:Second we make a call to Facebook API:
Observed Results:
We have the following error indicating the we try to parse something that is not parseable:
Doing some research, it comes from the fact that we try to parse the response body which is equal to 'Sorry, this content isn't available right now', this causes a
JSON::ParserError
.File responsible:
lib/facebook_ads/api_response.rb
Code responsible:Expected Results:
It should: