Executar uma Api interna dentro de uma Form ou dentro de uma outra Api
No FormContext
Chamando uma Api Post e aguardando a resposta (sincronamente).
public async Task ExecuteAsync(){
var result = await FormContext.InternalApi.ExecutePostSynchronouslyAsync("rest-api/teste",
new { valorr= 33445566.77 },
new ExecutePostSynchronouslyOptions() {
AuthUser = "apiUserLogin",
AuthKey = "apiUserKey",
});
//verificar se foi sucesso ou nao
var isSuccess = result.IsSuccess;
//se quiser o retorno no formato string
var str = result.GetString();
//se quiser o retorno no formato Json
var json = result.GetJson();
FormContext.Log($"isSuccess: {isSuccess} | - str: {str}" ,"debug");
}
Chamando uma Api Post e não aguardando a resposta (assincronamente).
public async Task ExecuteAsync(){
await FormContext.InternalApi.ExecutePostAsynchronouslyAsync("rest-api/teste",
new { valorr= 334455.66 },
new ExecutePostAsynchronouslyOptions() {
AuthUser = "apiUserLogin",
AuthKey = "apiUserKey",
});
}
No ApiContext
Chamando uma Api Post e aguardando a resposta (sincronamente).
public async Task RunAsync(){
var result = await ApiContext.InternalApi.ExecutePostSynchronouslyAsync("rest-api/teste",
new { valorr= 33445566.77 },
new ExecutePostSynchronouslyOptions() {
AuthUser = "apiUserLogin",
AuthKey = "apiUserKey",
});
//verificar se foi sucesso ou nao
var isSuccess = result.IsSuccess;
//se quiser o retorno no formato string
var str = result.GetString();
//se quiser o retorno no formato Json
var json = result.GetJson();
FormContext.Log($"isSuccess: {isSuccess} | - str: {str}" ,"debug");
}
Chamando uma Api Post e não aguardando a resposta (assincronamente).
public async Task RunAsync(){
await ApiContext.InternalApi.ExecutePostAsynchronouslyAsync("rest-api/teste",
new { valorr= 334455.66 },
new ExecutePostAsynchronouslyOptions() {
AuthUser = "apiUserLogin",
AuthKey = "apiUserKey",
});
}