Calling and creating a Stream with Cloud REST API from .NET

I’m trying to use the HTTP client in .NET to call the Cloud REST API

Getting an unauthorized error. How should I be passing the keys across in the call?

Here’s my code:

var client = new HttpClient();

var values = new List<KeyValuePair<string, string>>();

string url = “https://api.cloud.wowza.com/api/v1/live_streams/”;

client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(“wsc-api-key”, “MYAPIKEY”); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(“wsc-access-key”, “MYACCESSKEY”);

values.Add(new KeyValuePair<string, string>(“name”, “MyNewLiveStream”));

values.Add(new KeyValuePair<string, string>(“transcoder_type”, “transcoded”));

values.Add(new KeyValuePair<string, string>(“billing_mode”, “pay_as_you_go”));

values.Add(new KeyValuePair<string, string>(“broadcast_location”, “us_west_california”)); values.Add(new KeyValuePair<string, string>(“encoder”, “other_rtmp”));

values.Add(new KeyValuePair<string, string>(“delivery_method”, “push”));

values.Add(new KeyValuePair<string, string>(“aspect_ratio_width”, “1920”));

values.Add(new KeyValuePair<string, string>(“aspect_ratio_height”, “1080”));

var content = new FormUrlEncodedContent(values);

var response = await client.PostAsync(url, content);


Response:

StatusCode: 401, ReasonPhrase: ‘Unauthorized’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Access-Control-Allow-Credentials: true Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-PINGOTHER,Content-Type,MaxDataServiceVersion,DataServiceVersion,Authorization,X-Requested-With,If-Modified-Since,Cookie,wsc-api-key,wsc-access-key Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE Access-Control-Allow-Origin: * Status: 401 Unauthorized X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Request-Id: 66bf20b9-98c9-45c3-8d2b-2877c1346ced X-Runtime: 0.004638 X-XSS-Protection: 1; mode=block Connection: keep-alive Cache-Control: no-cache Date: Wed, 17 May 2017 22:59:14 GMT Server: nginx/1.7.2 X-Powered-By: Phusion Passenger 5.0.14 Content-Length: 143 Content-Type: application/json; charset=utf-8 }