
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2019 05:12 AM
Hi,
I am writing a code in C# to call the servicenow Table API to retrieve the change_request rows. I am able to do this by setting Authorization to Basic with some value. It is working as expected since I took the authorization code from some other .NET application which was developed 3 years back.
My question is where should I navigate to see the authorization value in ServiceNow? Where do we set this ?
Any pointers would be great so that I can be sure that if someone changes that, I will be able to update my codebase accordingly.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 12:59 AM
i am adding one sample code here.
can you try to set like the same way.
Uri sNowURI = new Uri("https://myinstance.service-now.com/api/now/table/mytable");
rest.BaseAddress = sNowURI;
rest.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "user", "password"))));
rest.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await rest.GetAsync(sNowURI);
if (response.IsSuccessStatusCode)
{
var contents = await response.Content.ReadAsStringAsync();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2019 07:08 PM
Hi Harsh,
Where exactly do you set that user up for Basic Authentication ? Are you using hardcoded username/password in your code to call that ? Or you are using some sort of encryption so that the username and password are hidden ?
This is how I am using the authorization code in my .NET application :
I want to know how can I get the encrypted value of the username/password which I have setup in the above example ? Where can I navigate in SNOW to do it ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 12:59 AM
i am adding one sample code here.
can you try to set like the same way.
Uri sNowURI = new Uri("https://myinstance.service-now.com/api/now/table/mytable");
rest.BaseAddress = sNowURI;
rest.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "user", "password"))));
rest.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await rest.GetAsync(sNowURI);
if (response.IsSuccessStatusCode)
{
var contents = await response.Content.ReadAsStringAsync();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2019 12:01 PM