When I try to get the final CSID after I submitted the three invoices successfully I get an error saying You are not authorized to use this api endpoint
what should I pass to the api beside the Request ID
Thanks in advance
API link:
https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/production/csids
Error:
You are not authorized to use this api endpoint
{StatusCode: 401, ReasonPhrase: ‘Unauthorized’, Version: 1.1, Content:
Dear @Ibrahime
Thanks for reaching out, Welcome to our community.
To provide comprehensive support as usual, Can I kindly ask you to provide the following:
- What are the exact steps you followed from the CSR generation?
- What are the APIs that you are hitting?
- Providing screenshots will help us in our investigation to ensure providing the needed help.
Thanks,
Ibrahem Daoud.
here is the API link:
https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/production/csids
Here is how to call it from C#
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, apiUrl);
request.Headers.Add("accept", "application/json");
request.Headers.Add("Authorization", "Basic aWJyYWhpbWUyMDAwQGdtYWlsLmNvbTpJZmVrcmFTb2Z0QDA=");
request.Headers.Add("Accept-Version", "V2");
request.Content = new StringContent("{\n \"compliance_request_id\": \"" + RequestID + "\"\n}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await client.SendAsync(request);
string responseBody = await response.Content.ReadAsStringAsync();
Check your Authorization Header, this should from CCSIDBinarySecurityToken:CCSID Secret
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{CCSIDBinaryToken}:{CCSIDSecret}")));