2024 Sep 03 2:33 PM - edited 2024 Sep 04 7:15 AM
Hi all,
I'm only been able to call '/raylight/v1/about' with success. all other calls e.g /session return 401
I have been able to authenticate and return a token which I use in the subsequent calls. Below is a pared down version of the code in C#:
using (var client = new System.Net.Http.HttpClient())
{
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
var response = await client.GetAsync("http://servername:8080/biprws/raylight/v1/session");
GD.Print("response" + response);
return "ok";
}
I have administrator privileges. I was wondering if I needed to do some further setup in the system or the token format is not correct? The token is taken from this response:
responseStatusCode: 200, ReasonPhrase: '', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Date: Tue, 03 Sep 2024 06:13:08 GMT
X-SAP-LogonToken: "everything between the double quotes is extracted"
Vary: accept-encoding
Transfer-Encoding: chunked
Content-Type: application/xml
}
Any help would be appreciated.
update: I think I am missing something like this
client.DefaultRequestHeaders.Add("X-SAP-LogonToken", $"\"{token}\"");
or
client.DefaultRequestHeaders.Add("X-SAP-LogonToken", token});
instead or along with
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
Addendum update after solution:
In my case I removed:
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);and replaced with:
client.DefaultRequestHeaders.Add("X-SAP-LogonToken", token);Thanks,
Paul
Request clarification before answering.
Yes, after you have logged in and received the LogonToken (response from the logon call)), you should include the token in the “X-SAP-LogonToken” header on every RESTful call.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 11 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.