[go: up one dir, main page]

0% found this document useful (0 votes)
15 views2 pages

API

Uploaded by

umar fayyaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

API

Uploaded by

umar fayyaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

app.

MapPost("/GetDirectUser", [Authorize] async (HttpContext httpContext) =>


{
try
{
var requestModel = await
httpContext.Request.ReadFromJsonAsync<RequestModel>();
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json, text/plain,
*/*");
client.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.9");
client.DefaultRequestHeaders.Add("Referer",
"https://beta.smartservices.icp.gov.ae/echannels/web/client/guest/index.html");
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT
10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0
Safari/537.36");
client.DefaultRequestHeaders.Add("languageId", "2");

var response =
client.GetAsync("https://beta.smartservices.icp.gov.ae/echannels/api/api/user/
guest/login").Result;
var json = response.Content.ReadAsStringAsync().Result;
var jsonObject = JObject.Parse(json);

client.DefaultRequestHeaders.Add("userToken",
jsonObject["userToken"]?.ToString());
client.DefaultRequestHeaders.Add("refreshToken",
jsonObject["refreshToken"]?.ToString());
client.DefaultRequestHeaders.Add("CURRENT_PORTAL", "ICA");
var country = CountryList.Get().Where(x => x.CountryName ==
requestModel.Country.ToUpper()).FirstOrDefault();
int coId = 0;
if (country != null)
{
coId = country.CountryID;
}
var requestData = new
{
request = new
{
IdentificationType = 1,
FileModuleId = 2,
PersonUnifiedNumber = requestModel.UnifiedNumber,
CurrentNationalityId = coId,
DateOfBirth = requestModel.DOB,
ApplicantMobile = "00971555555555",
ApplicantEmail = "a@a.com"
},
ServiceTransactionId = "588",
AdministrativeRegionId = "1",
WithException = false,
CurrentStep = "leavePermitRequest.step2",
RequestNumber = "0001226715442025510506745",
Id = 211633950
};
var jsonContent = new StringContent(JsonSerializer.Serialize(requestData),
Encoding.UTF8, "application/json");
var response2 = await
client.PostAsync("https://smartservices.icp.gov.ae/echannels/api/api/leavePermit/
draft/add", jsonContent);

var json2 = response2.Content.ReadAsStringAsync().Result;

var leavePermitRequest =
JsonSerializer.Deserialize<LeavePermitRequest>(json2, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
return leavePermitRequest.Request;
}
catch (Exception ex)
{
throw new Exception("Something went wrong...");
}
});

You might also like