views:

79

answers:

2

I'm trying to retrieve my contacts using curl. I've succeeded in getting my authToken, and now am getting an error stating that I need to set the content-length in the header, but when I set the content length to 0 I get a "bad request" error. Does anyone know what the content length is? Is it the length of the Auth key? or the length of the entire header field that contains it? I'm just poking around in the dark, and the google api doesn't seem to explain what it's looking for.

A: 

According to the HTTP standard, content-length must be greater then or equal to zero. This header can cause a "bad request" problem if:

  • A 'transfer-encoding' header is included in the request with certain values or
  • If the content-length is less than the actual length
  • A content-length less than zero is sent

Content length should be the size of the message body (not including headers). This would include POST data (presumably how your authToken is sent) sent with the request.

The length sent shouldn't need to be exact (though you should try!). Most browsers don't care about the length (as long as it is greater than the actual content length). If it is less than the actual content length, most browsers choke, but not the other way around. I'm assuming Google's servers will act similarly.

Dan Herbert
no, the authToken is sent in as a header. So, if I understand correctly the length SHOULD be 0? That doesn't seem to work.
Dr.Dredel
A: 

So, the solution appears to be that a) the second request is a GET not a POST and b) the username I was passing in requires a fully qualified email ([email protected], not just boo)

Dr.Dredel