REST JSON GET - 400 Bad Request

I am working with the Basecamp API which is a REST (JSON) API using basic HTTP authentication over HTTPS.

This should be a GET request but when I run my code using GET I am receiving:

Cannot send a content-body with this verb-type

When I run it as a POST, I receive:

{"status":"400","error":"Bad Request"}

Does anyone know why this may be occurring?

    using (var httpClient = new HttpClient()) {

        string userName = "";
        string password = "somepassword";

        var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", userName, password)));

        httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);

        HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, "https://correctUrlHere);
        requestMessage.Headers.Add("User-Agent", "TheProject (");
        requestMessage.Content = new StringContent(string.Empty, Encoding.UTF8, "application/json");

        var response = await httpClient.SendAsync(requestMessage);

        var responseContent = await response.Content.ReadAsStringAsync();


In this code I obviously swapped out the username, password, project name, and URL but in the actual code they are all correct.


GET requests must pass their parameters as url query and not as request body. 

If you don't have any content, as your example suggests, omit setting it on the request.

The BadRequest result indicates some error with your payload (again: content seems to be empty).

Need Your Help

Detect iPad version - php

php ios ipad user-agent

I am currently checking if a device is an iPad or not using the following code

Captcha for Joomla 1.5 and VirtueMart 1

php javascript joomla captcha virtuemart

I have a website running on Joomla 1.5 with the old Virtuemart installed. Is there a captcha extension which can be used for VirtueMart product enquiry form. I have tried and looked all over the we...