I am trying to create a session using c# code and am getting the weirdest error while creating a session (Note it does work through postman)
{"exception_body":{"http_response_code":401, "message":"No session exists.", "debug_message":"No session exists.","error_code":1000}}
Which is odd because I know the session does not exist I am trying to create it
Here is my c# code
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(baseUrl);
client.DefaultRequestHeaders.Host = "dev.XXXX.cloud.opentext.com";
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("X-Requested-With", "XMLHttpRequest");
var formConent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("username", userName),
new KeyValuePair<string, string>("password", password),
});
HttpResponseMessage response;
ApiResponse apiResponse = new ApiResponse();
try
{
response = await client.PostAsync("/otmmapi/v5/sessions", formConent);
var responseJson = await response.Content.ReadAsStringAsync();
....
I have tried with and without the Host, X-Requested-With and Accept Headers
Also I always get the same response whether or not the username and password is correct
It is returning the same error code as a GET but I confirmed it is actually doing a post
{Method: POST, RequestUri:
'https://dev.****.cloud.opentext.com/otmmapi/v5/sessions',
Version: 1.1, Content: System.Net.Http.FormUrlEncodedContent, Headers:
{
Accept: application/json
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded
Content-Length: 49
}}
It does not work using the javascript sample code, I get a Xorigin error when trying to run the same code
jQuery.ajax({ url : "https://dev.XXXX.cloud.opentext.com/otmmapi/v5/sessions", method: "POST",
data: {"username" : "", "password" : ""}})
.done(function() { console.log("dfsaf") })
.fail(function(req, res, data) {console.log(req, res, data)})