Getting 404 on favorite/create but not on follow/create endpoint, despite same tokens


#1

I’m getting a 404 on this:

favorite tweet

	if 'favorite_tweet' in message.keys():
		# fav a tweet (on rawger and/or twitter)
		print 'favorite tweet: ', message
		print int(message['favorite_tweet'])
		try:
			self.twitter_request(
				"https://api.twitter.com/1.1/favorites/create.json",
					access_token=self.twitter_access_token,
					callback=self.async_callback(self._on_post),
					post_args={'id' : int(message['favorite_tweet'])}	# tweet id, not twitter id
				)		
		except Exception:
			print sys.exc_info()[1:3]
			print 'error favstarring'
			pass

But not on this:

follow twitter user

	if 'follow_tweep' in message.keys():
		try:
			print int(message['follow_tweep'])
			self.twitter_request(
				"https://api.twitter.com/1.1/friendships/create.json",
					access_token=self.twitter_access_token,
					callback=self.async_callback(self._on_post),
					post_args={'id' : int(message['follow_tweep'])}
				)
		except Exception:
			print sys.exc_info()[1:3]
			print 'error favstarring'
			pass

The code is IDENTICAL - except tweet ID instead of tweep ID, and the endpoint obviously. Seems like a mysterious error, would really appreciate any help!

(Btw, when previewing this submit, the Subject and Category fields are nulled.)


#2

Does anybody else have problems with the favorite/create endpoint? I’d really appreciate some insight on this!


#3

I have the same problem with favorites/create and also with statuses/retweet/[id].json.

Both give me 404 errors.


#4

I’ve not been able to reproduce this. Are you sure that the ID you’re trying to retweet or favorite actually belongs to a tweet that exists? Where are you getting the ID value from? Are you getting it from the id_str attached to a tweet or from the id attached? Are you using a language or environment that may not be able to consume 64-bit integers? If so, you may be thinking you’re using the right tweet ID but are in fact using a tweet ID that has been silently munged by your environment.


#5

Thank You :slight_smile:
Somehow the browser replaced the last two digits of the id by zero.
Using id_str resolved that problem.


#6

Yes, browsers (pretty much anything Javascript-based or consuming JSON according to Javascript specifications) will have trouble with our integers. Whenever possible, use id_str values instead and treat our IDs as strings.


#7

What’s the value of sys.maxint on your platform? Python int is only guaranteed a minimum of 32 bits of precision, which is insufficient for Tweet IDs.