API Auth using c#

Solved
xapogo
Tourist
9 2 3

Hi, i'm trying to connect to te api usng c# to a demo site but i'm receiving error 401 not authorized.

I use this code and i need help to get the response OK.

Could you help me please?

 

 

public static void GETShopify(string CallLoc, string APIKey, string Password, string StoreName)
{
string Str = APIKey + ":" + Password;
byte[] byt = System.Text.Encoding.UTF8.GetBytes(Str);
Str = System.Convert.ToBase64String(byt);

string Url = "https://" + StoreName + ".myshopify.com/admin/" + CallLoc;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
WebRequest request = WebRequest.Create(Url);
WebResponse response = null;

NetworkCredential SimpleCredential = new NetworkCredential(APIKey, Password);
request.Credentials = SimpleCredential;
request.Headers.Add("Authorization", "Basic " + Str);
request.ContentType = "application/json";
request.Method = "GET";

try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception a)
{
Console.WriteLine(a.ToString());
}
}

Accepted Solution (1)

Accepted Solutions
xapogo
Tourist
9 2 3

This is an accepted solution.

I find the solution in the site and not in the partner portal.

So in the site i have to enable private apps.

View solution in original post

Reply 1 (1)
xapogo
Tourist
9 2 3

This is an accepted solution.

I find the solution in the site and not in the partner portal.

So in the site i have to enable private apps.