using (var httpClient = new HttpClient())
{
httpClient.BaseAddress = new Uri("https://platform.clickatell.com/");
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "wyOtm7-eRq-dSHWORr6hfw==");
var stringContent = new StringContent("{\"content\":\"Test Message\",\"to\":[\"61400000000\"]}");
stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var httpResponseMessage = AsyncHelper.RunSync(() => httpClient.PostAsync("messages", stringContent));
var result = httpResponseMessage.Content.ReadAsStringAsync().Result;
}
result is: {"messages":[],"error":"Invalid or missing Integration API Key. - "}
But my API Key is exactly as defined by Clickatell.
Additional info: The Clickatell site displays the following Json curl call (note: I can't get curl working in order to test it).
CURL CALL:
==========
curl -i \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: wyOtm7-eRq-dSHWORr6hfw==" \
-d '{"content": "Test Message Text", "to": ["61400000000"], "from": "+1234567890"}' \
-s https://platform.clickatell.com/messages
The only difference is that I am specifying my token as a bearer token. Without it I get a format exception.
Thankyou to anyone who may be able to shed some light on my issue.