Serenity: Call Services

Created on 16 Jun 2016  路  6Comments  路  Source: serenity-is/Serenity

How to call service from another application with ServiceAuthorize?
Please help me.

Thanks.

Most helpful comment

Use JsonServiceClient from Serenity.Services:

var client = new JsonServiceClient("http://www.mysite.com/");
var client = new JsonServiceClient("http://www.mysite.com/");
client.Post<ServiceResponse>("Account/Login", 
    new LoginRequest {
        Username = "someuser",
        Password = "somepass"
    });

var list = client.Post<ListResponse<Dictionary<string, object>>>(
    "Services/Northwind/Customer/List", 
    new ListRequest {
        Take = 100
    });

All 6 comments

The ServiceAuthorize() attribute is part of the permissions system _inside_ of Serenity. When placed above a controller method in XYZEndpoint.cs, it checks that the user is currently logged in. If you're going to call a service from an external application, you'll have to add the service to your controller manually.

Use JsonServiceClient from Serenity.Services:

var client = new JsonServiceClient("http://www.mysite.com/");
var client = new JsonServiceClient("http://www.mysite.com/");
client.Post<ServiceResponse>("Account/Login", 
    new LoginRequest {
        Username = "someuser",
        Password = "somepass"
    });

var list = client.Post<ListResponse<Dictionary<string, object>>>(
    "Services/Northwind/Customer/List", 
    new ListRequest {
        Take = 100
    });

Thanks mr. volkanceylan

Hey @volkanceylan It's possible install Serenity.Services in Xamarin? I have some problems... Thanks

Take code for ServiceClient, modify it a bit.

Hi,
I am getting an error on new LoginRequest how to create this object?? or am I missing any reference??

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kilroyFR picture kilroyFR  路  3Comments

john20xdoe picture john20xdoe  路  3Comments

chintankukadiya18 picture chintankukadiya18  路  3Comments

Pinellus picture Pinellus  路  3Comments

AmuthaKondusamy picture AmuthaKondusamy  路  3Comments