Get Contact - 400 Error - Bad Request

Hi
Why do I receive a 400 when retrieving contacts?


400 Bad Request

400 Bad Request



cloudflare


GET
https:///,/api/3/contacts?status=-1

MY CODE LOOKS LIKE THIS… any ideas? Thx in advance

var client = new RestClient(“https://XXXXX.api-us1.com/api/3/contacts?status=-1”);

client.Timeout = -1;

var request = new RestRequest(Method.GET);

request.AddHeader(“Api-Token”, “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”);

request.AddParameter(“text/plain”, “”, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

Console.WriteLine(response.Content);

I removed this … request.AddParameter(“text/plain”, “”, ParameterType.RequestBody);
Same result

Hey!

It looks like you’re using .Net and RestSharp, correct? Here’s an example that I think will work for you.

// Get these from a config file instead of hard-coding
const string hostName = "yourHostName";
const string token = "yourApiToken";

// Create the client (one instance for the entire app)
var client = new RestClient($"https://{ hostName }.api-us1.com/api/3");
client.AddDefaultHeader("Api-Token", token);
client.AddDefaultHeader("Content-Type", "application/json");
client.AddDefaultHeader("Accept", "application/json");

// create and execute a request
var request = new RestRequest("contacts", Method.GET);
request.AddParameter("status", -1);
var response = client.Execute(request);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Content);