Skip to main content
Rollback to Revision 1
Source Link
musefan
  • 48.5k
  • 21
  • 144
  • 193

I am working on a side project at work (I'm not a developer).

What I'm trying to achieve is validating whether statusis NULL or it has ERR in the login request response so I can know if I may continue the process.

This is the code I have so far:

namespace EseyeSIMAPI
{
class Program
{
    static void Main(string[] args)
    {
        var client = new RestClient("https://siam.eseye.com/Japi/Tigrillo");
        var loginRequest = new RestRequest("/login/", Method.POST);

        loginRequest.AddHeader("postman-token", "4e67ed4c-4130-4067-9539-d5ed6b6ad761");
        loginRequest.AddHeader("cache-control", "no-cache");
        loginRequest.AddHeader("content-type", "application/json");
        loginRequest.AddParameter("application/json", "{\r\n\"username\" : \"someusername\" ,\r\n\"password\" : \"somepassword\" ,\r\n\"portfolioID\" : \"someportfolioid\"\r\n}", ParameterType.RequestBody);

        IRestResponse response = client.Execute(loginRequest);

        client.ExecuteAsync(loginRequest, x =>
        {
            var json = x.Content;
        });

        Console.ReadLine();
    }
}
public class LoginStatus
{
    public Status status { get; set; }
    public string cookie { get; set; }
    public string permissions { get; set; }
    public string canActivate { get; set; }
}

public class Status
{
    public string errorCode { get; set; }
    public string errorMessage { get; set; }
    public string status { get; set; }
}
}

I receive the following JSON response:

{
"status": {
"errorCode": "",
"errorMessage": "",
"status": "OK"
},
"cookie": "2p255ju6q1lfql594uppnq9lp2",
"permissions": "ULE",
"canActivate": "yes"
}

So I created a class that will handle all the response parameters in the JSON object. I'm just not sure how exactly to access status.

I solved this by using IRestResponse<LoginStatus> response = client.Execute<LoginStatus>(loginRequest);

I am working on a side project at work (I'm not a developer).

What I'm trying to achieve is validating whether statusis NULL or it has ERR in the login request response so I can know if I may continue the process.

This is the code I have so far:

namespace EseyeSIMAPI
{
class Program
{
    static void Main(string[] args)
    {
        var client = new RestClient("https://siam.eseye.com/Japi/Tigrillo");
        var loginRequest = new RestRequest("/login/", Method.POST);

        loginRequest.AddHeader("postman-token", "4e67ed4c-4130-4067-9539-d5ed6b6ad761");
        loginRequest.AddHeader("cache-control", "no-cache");
        loginRequest.AddHeader("content-type", "application/json");
        loginRequest.AddParameter("application/json", "{\r\n\"username\" : \"someusername\" ,\r\n\"password\" : \"somepassword\" ,\r\n\"portfolioID\" : \"someportfolioid\"\r\n}", ParameterType.RequestBody);

        IRestResponse response = client.Execute(loginRequest);

        client.ExecuteAsync(loginRequest, x =>
        {
            var json = x.Content;
        });

        Console.ReadLine();
    }
}
public class LoginStatus
{
    public Status status { get; set; }
    public string cookie { get; set; }
    public string permissions { get; set; }
    public string canActivate { get; set; }
}

public class Status
{
    public string errorCode { get; set; }
    public string errorMessage { get; set; }
    public string status { get; set; }
}
}

I receive the following JSON response:

{
"status": {
"errorCode": "",
"errorMessage": "",
"status": "OK"
},
"cookie": "2p255ju6q1lfql594uppnq9lp2",
"permissions": "ULE",
"canActivate": "yes"
}

So I created a class that will handle all the response parameters in the JSON object. I'm just not sure how exactly to access status.

I solved this by using IRestResponse<LoginStatus> response = client.Execute<LoginStatus>(loginRequest);

I am working on a side project at work (I'm not a developer).

What I'm trying to achieve is validating whether statusis NULL or it has ERR in the login request response so I can know if I may continue the process.

This is the code I have so far:

namespace EseyeSIMAPI
{
class Program
{
    static void Main(string[] args)
    {
        var client = new RestClient("https://siam.eseye.com/Japi/Tigrillo");
        var loginRequest = new RestRequest("/login/", Method.POST);

        loginRequest.AddHeader("postman-token", "4e67ed4c-4130-4067-9539-d5ed6b6ad761");
        loginRequest.AddHeader("cache-control", "no-cache");
        loginRequest.AddHeader("content-type", "application/json");
        loginRequest.AddParameter("application/json", "{\r\n\"username\" : \"someusername\" ,\r\n\"password\" : \"somepassword\" ,\r\n\"portfolioID\" : \"someportfolioid\"\r\n}", ParameterType.RequestBody);

        IRestResponse response = client.Execute(loginRequest);

        client.ExecuteAsync(loginRequest, x =>
        {
            var json = x.Content;
        });

        Console.ReadLine();
    }
}
public class LoginStatus
{
    public Status status { get; set; }
    public string cookie { get; set; }
    public string permissions { get; set; }
    public string canActivate { get; set; }
}

public class Status
{
    public string errorCode { get; set; }
    public string errorMessage { get; set; }
    public string status { get; set; }
}
}

I receive the following JSON response:

{
"status": {
"errorCode": "",
"errorMessage": "",
"status": "OK"
},
"cookie": "2p255ju6q1lfql594uppnq9lp2",
"permissions": "ULE",
"canActivate": "yes"
}

So I created a class that will handle all the response parameters in the JSON object. I'm just not sure how exactly to access status.

added 111 characters in body
Source Link
Ko Ga
  • 934
  • 1
  • 19
  • 30

I am working on a side project at work (I'm not a developer).

What I'm trying to achieve is validating whether statusis NULL or it has ERR in the login request response so I can know if I may continue the process.

This is the code I have so far:

namespace EseyeSIMAPI
{
class Program
{
    static void Main(string[] args)
    {
        var client = new RestClient("https://siam.eseye.com/Japi/Tigrillo");
        var loginRequest = new RestRequest("/login/", Method.POST);

        loginRequest.AddHeader("postman-token", "4e67ed4c-4130-4067-9539-d5ed6b6ad761");
        loginRequest.AddHeader("cache-control", "no-cache");
        loginRequest.AddHeader("content-type", "application/json");
        loginRequest.AddParameter("application/json", "{\r\n\"username\" : \"someusername\" ,\r\n\"password\" : \"somepassword\" ,\r\n\"portfolioID\" : \"someportfolioid\"\r\n}", ParameterType.RequestBody);

        IRestResponse response = client.Execute(loginRequest);

        client.ExecuteAsync(loginRequest, x =>
        {
            var json = x.Content;
        });

        Console.ReadLine();
    }
}
public class LoginStatus
{
    public Status status { get; set; }
    public string cookie { get; set; }
    public string permissions { get; set; }
    public string canActivate { get; set; }
}

public class Status
{
    public string errorCode { get; set; }
    public string errorMessage { get; set; }
    public string status { get; set; }
}
}

I receive the following JSON response:

{
"status": {
"errorCode": "",
"errorMessage": "",
"status": "OK"
},
"cookie": "2p255ju6q1lfql594uppnq9lp2",
"permissions": "ULE",
"canActivate": "yes"
}

So I created a class that will handle all the response parameters in the JSON object. I'm just not sure how exactly to access status.

I solved this by using IRestResponse<LoginStatus> response = client.Execute<LoginStatus>(loginRequest);

I am working on a side project at work (I'm not a developer).

What I'm trying to achieve is validating whether statusis NULL or it has ERR in the login request response so I can know if I may continue the process.

This is the code I have so far:

namespace EseyeSIMAPI
{
class Program
{
    static void Main(string[] args)
    {
        var client = new RestClient("https://siam.eseye.com/Japi/Tigrillo");
        var loginRequest = new RestRequest("/login/", Method.POST);

        loginRequest.AddHeader("postman-token", "4e67ed4c-4130-4067-9539-d5ed6b6ad761");
        loginRequest.AddHeader("cache-control", "no-cache");
        loginRequest.AddHeader("content-type", "application/json");
        loginRequest.AddParameter("application/json", "{\r\n\"username\" : \"someusername\" ,\r\n\"password\" : \"somepassword\" ,\r\n\"portfolioID\" : \"someportfolioid\"\r\n}", ParameterType.RequestBody);

        IRestResponse response = client.Execute(loginRequest);

        client.ExecuteAsync(loginRequest, x =>
        {
            var json = x.Content;
        });

        Console.ReadLine();
    }
}
public class LoginStatus
{
    public Status status { get; set; }
    public string cookie { get; set; }
    public string permissions { get; set; }
    public string canActivate { get; set; }
}

public class Status
{
    public string errorCode { get; set; }
    public string errorMessage { get; set; }
    public string status { get; set; }
}
}

I receive the following JSON response:

{
"status": {
"errorCode": "",
"errorMessage": "",
"status": "OK"
},
"cookie": "2p255ju6q1lfql594uppnq9lp2",
"permissions": "ULE",
"canActivate": "yes"
}

So I created a class that will handle all the response parameters in the JSON object. I'm just not sure how exactly to access status.

I am working on a side project at work (I'm not a developer).

What I'm trying to achieve is validating whether statusis NULL or it has ERR in the login request response so I can know if I may continue the process.

This is the code I have so far:

namespace EseyeSIMAPI
{
class Program
{
    static void Main(string[] args)
    {
        var client = new RestClient("https://siam.eseye.com/Japi/Tigrillo");
        var loginRequest = new RestRequest("/login/", Method.POST);

        loginRequest.AddHeader("postman-token", "4e67ed4c-4130-4067-9539-d5ed6b6ad761");
        loginRequest.AddHeader("cache-control", "no-cache");
        loginRequest.AddHeader("content-type", "application/json");
        loginRequest.AddParameter("application/json", "{\r\n\"username\" : \"someusername\" ,\r\n\"password\" : \"somepassword\" ,\r\n\"portfolioID\" : \"someportfolioid\"\r\n}", ParameterType.RequestBody);

        IRestResponse response = client.Execute(loginRequest);

        client.ExecuteAsync(loginRequest, x =>
        {
            var json = x.Content;
        });

        Console.ReadLine();
    }
}
public class LoginStatus
{
    public Status status { get; set; }
    public string cookie { get; set; }
    public string permissions { get; set; }
    public string canActivate { get; set; }
}

public class Status
{
    public string errorCode { get; set; }
    public string errorMessage { get; set; }
    public string status { get; set; }
}
}

I receive the following JSON response:

{
"status": {
"errorCode": "",
"errorMessage": "",
"status": "OK"
},
"cookie": "2p255ju6q1lfql594uppnq9lp2",
"permissions": "ULE",
"canActivate": "yes"
}

So I created a class that will handle all the response parameters in the JSON object. I'm just not sure how exactly to access status.

I solved this by using IRestResponse<LoginStatus> response = client.Execute<LoginStatus>(loginRequest);

Post Closed as "Duplicate" by Nkosi c#
Source Link
Ko Ga
  • 934
  • 1
  • 19
  • 30

Parsing and validating JSON string in C#

I am working on a side project at work (I'm not a developer).

What I'm trying to achieve is validating whether statusis NULL or it has ERR in the login request response so I can know if I may continue the process.

This is the code I have so far:

namespace EseyeSIMAPI
{
class Program
{
    static void Main(string[] args)
    {
        var client = new RestClient("https://siam.eseye.com/Japi/Tigrillo");
        var loginRequest = new RestRequest("/login/", Method.POST);

        loginRequest.AddHeader("postman-token", "4e67ed4c-4130-4067-9539-d5ed6b6ad761");
        loginRequest.AddHeader("cache-control", "no-cache");
        loginRequest.AddHeader("content-type", "application/json");
        loginRequest.AddParameter("application/json", "{\r\n\"username\" : \"someusername\" ,\r\n\"password\" : \"somepassword\" ,\r\n\"portfolioID\" : \"someportfolioid\"\r\n}", ParameterType.RequestBody);

        IRestResponse response = client.Execute(loginRequest);

        client.ExecuteAsync(loginRequest, x =>
        {
            var json = x.Content;
        });

        Console.ReadLine();
    }
}
public class LoginStatus
{
    public Status status { get; set; }
    public string cookie { get; set; }
    public string permissions { get; set; }
    public string canActivate { get; set; }
}

public class Status
{
    public string errorCode { get; set; }
    public string errorMessage { get; set; }
    public string status { get; set; }
}
}

I receive the following JSON response:

{
"status": {
"errorCode": "",
"errorMessage": "",
"status": "OK"
},
"cookie": "2p255ju6q1lfql594uppnq9lp2",
"permissions": "ULE",
"canActivate": "yes"
}

So I created a class that will handle all the response parameters in the JSON object. I'm just not sure how exactly to access status.