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

**URL:** <https://community.wowza.com/t/calling-and-creating-a-stream-with-cloud-rest-api-from-net/48767>\
**Category:** Wowza Developer Dojo\
**Created:** [May 18, 2017, 10:24am UTC](https://community.wowza.com/t/calling-and-creating-a-stream-with-cloud-rest-api-from-net/48767 "2017-05-18T10:24:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Christensen](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@Andrew\_Christensen](https://community.wowza.com/u/Andrew_Christensen)\
**Post date:** [May 18, 2017, 10:24am UTC](https://community.wowza.com/t/calling-and-creating-a-stream-with-cloud-rest-api-from-net/48767/1 "2017-05-18T10:24:40Z")

</div>

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/](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 }
