Skip to content

users/me inaccurate error #3

@toddfries

Description

@toddfries

If I call /2/users/me?user.fields=lang (and I know lang is invalid) ... real api.x.com responds with:

{"errors":[{"parameters":{"user.fields":["connection_status,created_at,description,entities,id,location,most_recent_tweet_id,name,pinned_tweet_id,profile_banner_url,profile_image_url,protected,public_metrics,receives_your_dm,subscription_type,url,username,verified,verified_type,verified_followers_count,lang,discoverable_by_email,allow_contributor_request,withheld"]},"message":"The `user.fields` query parameter value [lang] is not one of [affiliation,confirmed_email,connection_status,created_at,description,entities,id,is_identity_verified,location,most_recent_tweet_id,name,parody,pinned_tweet_id,profile_banner_url,profile_image_url,protected,public_metrics,receives_your_dm,subscription,subscription_type,url,username,verified,verified_followers_count,verified_type,withheld]"},{"parameters":{"user.fields":["connection_status,created_at,description,entities,id,location,most_recent_tweet_id,name,pinned_tweet_id,profile_banner_url,profile_image_url,protected,public_metrics,receives_your_dm,subscription_type,url,username,verified,verified_type,verified_followers_count,lang,discoverable_by_email,allow_contributor_request,withheld"]},"message":"The `user.fields` query parameter value [discoverable_by_email] is not one of [affiliation,confirmed_email,connection_status,created_at,description,entities,id,is_identity_verified,location,most_recent_tweet_id,name,parody,pinned_tweet_id,profile_banner_url,profile_image_url,protected,public_metrics,receives_your_dm,subscription,subscription_type,url,username,verified,verified_followers_count,verified_type,withheld]"},{"parameters":{"user.fields":["connection_status,created_at,description,entities,id,location,most_recent_tweet_id,name,pinned_tweet_id,profile_banner_url,profile_image_url,protected,public_metrics,receives_your_dm,subscription_type,url,username,verified,verified_type,verified_followers_count,lang,discoverable_by_email,allow_contributor_request,withheld"]},"message":"The `user.fields` query parameter value [allow_contributor_request] is not one of [affiliation,confirmed_email,connection_status,created_at,description,entities,id,is_identity_verified,location,most_recent_tweet_id,name,parody,pinned_tweet_id,profile_banner_url,profile_image_url,protected,public_metrics,receives_your_dm,subscription,subscription_type,url,username,verified,verified_followers_count,verified_type,withheld]"}],"title":"Invalid Request","detail":"One or more parameters to your request was invalid.","type":"https://api.twitter.com/2/problems/invalid-request"}

whereas this playground 'simulator' responds with:

{
  "detail": "One or more parameters to your request was invalid.",
  "errors": [
    {
      "message": "invalid value \'lang\' at index 20: value must be one of: [affiliation confirmed_email connection_status created_at description entities id is_identity_verified location most_recent_tweet_id name parody pinned_tweet_id profile_banner_url profile_image_url protected public_metrics receives_your_dm subscription subscription_type url username verified verified_followers_count verified_type withheld]",
      "parameters": {
        "user.fields": [
          "connection_status,created_at,description,entities,id,location,most_recent_tweet_id,name,pinned_tweet_id,profile_banner_url,profile_image_url,protected,public_metrics,receives_your_dm,subscription_type,url,username,verified,verified_type,verified_followers_count,lang,discoverable_by_email,allow_contributor_request,withheld"
        ]
      }
    }
  ],
  "title": "Invalid Request",
  "type": "https://api.twitter.com/2/problems/invalid-request"
}

Several things stand out to me as 'different':

  1. space separated list vs comma separated list
  2. someday rename both to api.x.com vs api.twitter.com (yes I'm calling api.x.com)
  3. the list of items is not the same (api.x.com has more)
  4. api.x.com has no cr/lf but playground output does

Not sure if I should rely on this but its a pretty useful trick to realize if I give an invalid field it lists the valid fields. Except the playground doesn't quite simulate the same as api.x.com, I am not sure if the $HOME/.playground-openapi-cache.json is inaccurate or something else inside the go code is.

If I need to dig deeper feel free to give me a hint or two.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions