A) after Running the visual studio program.cs file add the OTP and base64 output to get CSID
Code:
using System.Net.Http;
using System.Net.Http.Headers;
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, “https://gw-fatoora.zatca.gov.sa/e-invoicing/developer-portal/compliance”);
request.Headers.Add(“accept”, “application/json”);
request.Headers.Add(“OTP”, “425204”);
request.Headers.Add(“Accept-Version”, “V2”);
request.Content = new StringContent(“{\n "csr": "TUlJQkpUQ0J6UUlCQURCRk1Rc3dDUVlEVlFRR0V3SlRRVEVQTUEwR0ExVUVDd3dHU21Wa1pHRm9NUlF3RWdZRApWUVFLREF0QmJFcGhZbkpwYzI5bWRERVBNQTBHQTFVRUF3d0dTbVZrWkdGb01GWXdFQVlIS29aSXpqMENBUVlGCks0RUVBQW9EUWdBRTVLSEQvN3FVMEdyL3c1Qmo1Y0FXaFhldWRWc0c2MUlDT2xxYmlPUE5LcTVqZmFDeDJyRmYKeTVyYW5wWndaRll1ZWQyRFg4bjFPQlhKYXhPek1QTUNGNkFwTUNjR0NTcUdTSWIzRFFFSkRqRWFNQmd3Q1FZRApWUjBUQkFJd0FEQUxCZ05WSFE4RUJBTUNCZUF3Q2dZSUtvWkl6ajBFQXdJRFJ3QXdSQUlnU3ZSY1BrWXJXc21NCjI4K0tmcFZiaXBCbHBHcGVGZzNraWNGU1VGYWY1ME1DSUQzZnppajE1QnBkUHdPaitsNVJQM1FwVEpwSlZQWHQKQjNFdHdob1lzd1lC"\n}”);
request.Content.Headers.ContentType = new MediaTypeHeaderValue(“application/json”);
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
F) Execution Output :
Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Program.$(String args) in C:\Users\Ishaa\source\repos\CSID\CSID\Program.cs:line 17
at Program.(String args)
C:\Users\Ishaa\source\repos\CSID\CSID\bin\Debug\net8.0\CSID.exe (process 22680) exited with code -532462766 (0xe0434352).
Press any key to close this window . . .