Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintype was not text, image, or querystring #286

Closed
louisguitton opened this issue May 23, 2016 · 2 comments
Closed

Maintype was not text, image, or querystring #286

louisguitton opened this issue May 23, 2016 · 2 comments

Comments

@louisguitton
Copy link

When trying to get posts of a page, you use this endopoint: pagename?fields=posts.limit(10)
Most of the posts are of this type:

      {
        "message": "Elle va faire battre votre ❤️ ! #EMEHARI #PlageDeLaBastille",
        "created_time": "2016-05-22T12:54:14+0000",
        "id": "103666283041018_1048666508540986"
      }

But some have one field more:

{
  "created_time": "2016-03-13T16:00:44+0000",
  "message": "E-MEHARI \"styled by Courrèges\" a électrisé le Salon de Genève !",
  "story": "Citroën added 4 new photos.",
  "id": "103666283041018_994707227270248"
}

When trying to retrieve Citroen.France 's last 50 posts, I get this error because of this field:

Traceback (most recent call last):
  File "myproject/myfacebookapiclient.py", line 21, in get_page_posts
    page_posts = graph.get_object(page_id, **args)
  File "myproject/src/facebook-sdk/facebook/__init__.py", line 106, in get_object
    return self.request(self.version + "/" + id, args)
  File "myproject/src/facebook-sdk/facebook/__init__.py", line 272, in request
    raise GraphAPIError('Maintype was not text, image, or querystring')
facebook.GraphAPIError: Maintype was not text, image, or querystring

I printed the header, and it looks like this:

{  
   "Content-Length":"108",
   "X-FB-Trace-ID":"H8Vc/+RKGp2",
   "Expires":"Sat, 01 Jan 2000 00:00:00 GMT",
   "X-FB-Rev":"2349332",
   "Connection":"keep-alive",
   "Pragma":"no-cache",
   "Cache-Control":"private, no-cache, no-store, must-revalidate",
   "Date":"Mon, 23 May 2016 09:29:08 GMT",
   "Facebook-API-Version":"v2.6",
   "Access-Control-Allow-Origin":"*",
   "Content-Type":"text/html",
   "X-FB-Debug":"R79ZCTpQx1n51dpXygxmEBADxwEWZxLbrEp8TcxDBLaRGYIPLOfwg9NmFMmN/oT4U6ixSauuDmV8MHnshQbr6Q=="
}

It looks like it's a new feature from Facebook, that the if/elif/else loop of the init.py file is not handling the way the API explorer is for example

@martey
Copy link
Member

martey commented May 23, 2016

I think this issue is a duplicate of #281 - the "Maintype was not text, image, or querystring" message is hiding the real error.

@martey martey closed this as completed May 23, 2016
@louisguitton
Copy link
Author

louisguitton commented May 23, 2016

Indeed, thanks for the really quick reply!
what I did is add these lines on line 270:

        elif "text/html" in headers['content-type']:
            result = response.json()

It's just temporary fixing but it does the trick for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants