Home > Software design >  RestSharp webservice Further requests
RestSharp webservice Further requests

Time:03-22

I need help ... When I use Postaman the 2 requests I make work correctly, but this code of mine only returns me the authentication correctly but when I create a new request, it does not return anything. The response_1 content returns this error: "{" error_code ":" platform.web_application "," correlation_id ":" d7em3oxz7ng6kh9qx977l3904 "," description ":" HTTP 404 Not Found "," description_translated ":" HTTP 404 Not Found ", "properties": null, "business_error": false} " and the ResponseUri of response_1 is concatenated with that of the authentication. I can't find the error.This is the c# code

var client = new RestSharp.RestClient(url   @"/authentication/sign_in");
           
            var request = new RestSharp.RestRequest(RestSharp.Method.POST);
            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", request.AddJsonBody(new { user = admUserPass[0], password = admUserPass[1] }), RestSharp.ParameterType.RequestBody);
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)768 | (SecurityProtocolType)3072;
            RestSharp.IRestResponse response = client.Execute(request);
           

            //response.StatusCode = "OK"


            request.Resource = url   @"/admin/users";
            request.Method = RestSharp.Method.GET;
            foreach (var cookie in response.Cookies)
            {
                request.AddCookie(cookie.Name, cookie.Value); 
            }
            request.AddHeader("content-type", "application/json");
            request.AddHeader("Accept", "application/json");
            RestSharp.IRestResponse response_1 = client.Execute(request);

CodePudding user response:

Create a new Request before executing the second client.Execute(...)

CodePudding user response:

OK I found the solution, my code is right but I am working to consume the Octane ALM API rest. adding this line in the request header "request.AddHeader("ALM_OCTANE_TECH_PREVIEW "," true ");" The request is working correctly. There is a discussion at this link https://community.microfocus.com/adtd/alm_octane/f/ngabetageneralbetaforum/161440/alm_octane_tech_preview-header-issue

  • Related