I’m integrating NetSuite Account API into Asp.Net c#, i’m getting unauhthorized error,
here is error message:
<code>{"type":"https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.2","title":"Unauthorized","status":401,"o:errorDetails":[{"detail":"Invalid login attempt. For more details, see the Login Audit Trail in the NetSuite UI at Setup > Users/Roles > User Management > View Login Audit Trail.","o:errorCode":"INVALID_LOGIN"}]}
</code>
<code>{"type":"https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.2","title":"Unauthorized","status":401,"o:errorDetails":[{"detail":"Invalid login attempt. For more details, see the Login Audit Trail in the NetSuite UI at Setup > Users/Roles > User Management > View Login Audit Trail.","o:errorCode":"INVALID_LOGIN"}]}
</code>
{"type":"https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.2","title":"Unauthorized","status":401,"o:errorDetails":[{"detail":"Invalid login attempt. For more details, see the Login Audit Trail in the NetSuite UI at Setup > Users/Roles > User Management > View Login Audit Trail.","o:errorCode":"INVALID_LOGIN"}]}
here is api base url:
<code>https://test123.suitetalk.api.netsuite.com/
</code>
<code>https://test123.suitetalk.api.netsuite.com/
</code>
https://test123.suitetalk.api.netsuite.com/
I try to use both HttpCLient and RestClient, but resposne error was same.
here is my RestClient code:
<code> var options = new RestClientOptions("https://test123.suitetalk.api.netsuite.com/")
{
MaxTimeout = -1,
};
var client = new RestSharp.RestClient(options);
var request = new RestRequest("services/rest/record/v1/account/100", Method.Get);
request.AddHeader("Authorization", "OAuth realm="dd",oauth_consumer_key="ff",oauth_token="ff",oauth_signature_method="HMAC-SHA256",oauth_timestamp="ss",oauth_nonce="ss",oauth_version="1.0",oauth_body_hash="rtr=",oauth_signature="dd="");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
</code>
<code> var options = new RestClientOptions("https://test123.suitetalk.api.netsuite.com/")
{
MaxTimeout = -1,
};
var client = new RestSharp.RestClient(options);
var request = new RestRequest("services/rest/record/v1/account/100", Method.Get);
request.AddHeader("Authorization", "OAuth realm="dd",oauth_consumer_key="ff",oauth_token="ff",oauth_signature_method="HMAC-SHA256",oauth_timestamp="ss",oauth_nonce="ss",oauth_version="1.0",oauth_body_hash="rtr=",oauth_signature="dd="");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
</code>
var options = new RestClientOptions("https://test123.suitetalk.api.netsuite.com/")
{
MaxTimeout = -1,
};
var client = new RestSharp.RestClient(options);
var request = new RestRequest("services/rest/record/v1/account/100", Method.Get);
request.AddHeader("Authorization", "OAuth realm="dd",oauth_consumer_key="ff",oauth_token="ff",oauth_signature_method="HMAC-SHA256",oauth_timestamp="ss",oauth_nonce="ss",oauth_version="1.0",oauth_body_hash="rtr=",oauth_signature="dd="");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
Here is code by using HttpClient,
<code> var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://test123.suitetalk.api.netsuite.com/services/rest/record/v1/account/111");
request.Headers.Add("Authorization", "OAuth realm="dd",oauth_consumer_key="ff",oauth_token="ff",oauth_signature_method="HMAC-SHA256",oauth_timestamp="ss",oauth_nonce="ss",oauth_version="1.0",oauth_body_hash="rtr=",oauth_signature="dd="");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
</code>
<code> var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://test123.suitetalk.api.netsuite.com/services/rest/record/v1/account/111");
request.Headers.Add("Authorization", "OAuth realm="dd",oauth_consumer_key="ff",oauth_token="ff",oauth_signature_method="HMAC-SHA256",oauth_timestamp="ss",oauth_nonce="ss",oauth_version="1.0",oauth_body_hash="rtr=",oauth_signature="dd="");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
</code>
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://test123.suitetalk.api.netsuite.com/services/rest/record/v1/account/111");
request.Headers.Add("Authorization", "OAuth realm="dd",oauth_consumer_key="ff",oauth_token="ff",oauth_signature_method="HMAC-SHA256",oauth_timestamp="ss",oauth_nonce="ss",oauth_version="1.0",oauth_body_hash="rtr=",oauth_signature="dd="");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
With both approach getting same error, when i try to test api in postman, then it is working successfully!
How i can resolve this issue into my code?
Anyone can help quickly?