I am trying to hit API from C# code using HTTP client but I am getting the result as unauthorized. If I try with postman it's working fine. what will the issue ?
Hi Vamsi
My C# application has the following 2 lines before the Convert.ToBase64String :
string mergedCredentials = string.Format("{0}:{1}", m_Username, m_Password);
byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials);
return Convert.ToBase64String(byteCredentials);
Try to see if that helps
Thanks Warren for responding.
I am getting the AuthCredentials in the perfect way. I think it's problem with the permissions. Do we need to enable any permission ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vamsi
If I'm correct, the call you're doing (https://hrbotdev.atlassian.net/rest/api/latest/issue) isn't valid, because it needs a further /ABC-123 passing in the issue key.
I tried your call but with my Jira name instead of hrbotdev and I received an error. I added a key and it worked, so I think you need
https://hrbotdev.atlassian.net/rest/api/latest/issue/ABC-1234
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
It mean you provide invalid credentials or you do not provide credentials at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, I am giving the creadentials.
string authCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(Username + ":" + Password));
client.DefaultRequestHeaders.Add("Authorization", "Basic " + authCredentials);
client.DefaultRequestHeaders.Add("Accept", "application/json");
var result = JsonConvert.SerializeObject(model);
var response = await client.PostAsync($"https://hrbotdev.atlassian.net/rest/api/latest/issue", new StringContent(result, Encoding.UTF8, "application/json"));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you somehow to see, what request is sent from your program? I usually use Fiddler for it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It means that your request, which is sent from your program, is different from postman. You need to see your request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, both are same. The following is the API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If they were same, then the result would be also same
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried with all those, I think it's not problem from coding side. Because when I tried the same request in others system postman, they also got Unauthorized status code. It means when we access it remotely It's not working. Do I need to enable any permission to access it globally in atlassian account ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, there is no permissions like this. You said before, that it worked in postman and now it does not work. What is the difference?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.