0

accept header required?

Hi folks -

I've been experimenting with using Python to access the user profiles API. I kept getting an "HTTP 406" error and eventually figured out that I wasn't sending an "Accept" header to the /v1/user/guid/profile endpoint. Once I added an "Accept: *" header everything just worked.

The HTTP spec says that the accept header is optional: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

"If no Accept header field is present, then it is assumed that the client accepts all media types. If an Accept header field is present, and if the server cannot send a response which is acceptable according to the combined Accept field value, then the server SHOULD send a 406 (not acceptable) response."

I'm using the standard python library urllib2 to make these requests. It's likely that other people using python will run into the same problem. Can you change your server so that it does not require the Accept header?

Here's the request I sent:

GET /v1/user/LZUVOREAAOVP5FCIEAEDJNN4CE/profile?oauth_nonce=6683328964200256&oauth_timestamp=1226009632&oauth_consumer_key=dj0yJmk9MVRreVc0RkRpcks2JmQ9WVdrOVZGUnhNWE5STldVbWNHbzlOa
mc0TVRFek56WXgmcz1jb25zdW1lcnNlY3JldCZ4PTQw&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token=A%3DrVkJTUfYogamgl26SVjjF9VX9F7a_eUW1jKMU7MiW8t3PZowO.9ill1XG6Q5ba5gZtal.s5pGK79VA
Gsfle0SVC5GT6NOHZvOQ13sY4QjfuyHpKRp8osNL2Y7xDiwilGFuCD3kqw7FBjGSgOv6EgKv4LxcQL4S
.
JYZguG1kAEqbtQK0XI_XwSy9s7X0LhidZfwXNXQ3kpg0iHR_IBhWYE7836pZkISnr7eA.PpUIt0tAPKc
v
N02k7ckGC6OQW3KlBSwYTMqMhHoyf1klhO_NmzZusMEGNfaji0AqUt8WILAEjenSn_hklts3p2t_GSVG
p
vEL.dMq_.4DeZ9qghUS0.v.x6djKkT0WogfBHJv4mrB6wkyYHB3pIxC.yalKm0YMD7QDFSIkdfjy82M5
r
.HseOtS.5z9UzoEHlcrrxh0DRbtLWDrZM1YUftCwpst_hsIeCq1LSza4QY2kDaSnOyS7RAeReZ_fNLNQ
I
TJKkzv907lQfjxe_khemoVBPG7y8MYCwj3NRGXngO3ef0PkVPVMjvyPYEc_8EL7_q2OTgoMvX.CArfmA
u
Cs8VRWyDx9v3RSOKI7.AP6cKaonTlrBzcRSDkWQ4M2fZxBNjnodwH3yu1UiFV1phYL0IEVbq1pzNMUwW
m
9ufEfqrgVbj1eEm7sqr5ibCj12hpkkxwCEz6zYH_F_jddUQw2bL2EFsQA--&oauth_signature=Tbv0kaPBhAj4
zWYtHAU5FSFd2Qk%3D HTTP/1.1
Host: social.yahooapis.com
Connection: close
Accept-encoding: chunked
User-agent: Python-urllib/2.4


Here's the response from your server:

HTTP/1.1 406 Not Acceptable
Date: Thu, 06 Nov 2008 22:13:52 GMT
P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
Vary: Authorization
X-Yahoo-Social-Host: ws8.socdir.sp1.yahoo.com
Cache-Control: private
Content-Length: 268
Content-Type:
Age: 0
Connection: close
Server: YTS/1.17.9

<?xml version="1.0" encoding="utf-8"?><error xmlns="http://social.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:uri="http://www.yahooapis.com/v1/errors/406" yahoo:language="en_US"><description>Not available</description></error>

by
1 Reply
  • use Accept = "*" always in all request. YAHOO says that it's not necessary but it is necessary.
    0

Recent Posts

in Social Directory API