Compliance CSID - Bad Request

Dears,
I am generating the CSR using the following batch file command:based on sdk-238-R3.3.5

call fatoora -csr -csrConfig csr-config-example-EN.properties -privateKey pri_key.pem -generatedCsr csr_generated_file.pem -pem

where the configuration file named "csr-config-example-EN.properties ised, is provided with the sdk-238-R3.3.5 having the following content:

csr.common.name=TST-886431145-399999999900003
csr.serial.number=1-TST|2-TST|3-ed22f1d8-e6a2-1118-9b58-d9a8f11e445f
csr.organization.identifier=399999999900003
csr.organization.unit.name=Riyadh Branch
csr.organization.name=Maximum Speed Tech Supply LTD
csr.country.name=SA
csr.invoice.type=1100
csr.location.address=RRRD2929
csr.industry.business.category=Supply activities

I got the following “csr_generated_file.pem”:

-----BEGIN CERTIFICATE REQUEST-----
MIICFjCCAbwCAQAwdTELMAkGA1UEBhMCU0ExFjAUBgNVBAsMDVJpeWFkaCBCcmFu
Y2gxJjAkBgNVBAoMHU1heGltdW0gU3BlZWQgVGVjaCBTdXBwbHkgTFREMSYwJAYD
VQQDDB1UU1QtODg2NDMxMTQ1LTM5OTk5OTk5OTkwMDAwMzBWMBAGByqGSM49AgEG
BSuBBAAKA0IABJle8IYEhvUv4v7+TVCwBk+IyVpvlFZj2V+l3yBAJqdcfpAngnHn
Kd7n2ojm6GE8GpuJGprmNuFJl7Dyt/Ft8KGggecwgeQGCSqGSIb3DQEJDjGB1jCB
0zAhBgkrBgEEAYI3FAIEFAwSWkFUQ0EtQ29kZS1TaWduaW5nMIGtBgNVHREEgaUw
gaKkgZ8wgZwxOzA5BgNVBAQMMjEtVFNUfDItVFNUfDMtZWQyMmYxZDgtZTZhMi0x
MTE4LTliNTgtZDlhOGYxMWU0NDVmMR8wHQYKCZImiZPyLGQBAQwPMzk5OTk5OTk5
OTAwMDAzMQ0wCwYDVQQMDAQxMTAwMREwDwYDVQQaDAhSUlJEMjkyOTEaMBgGA1UE
DwwRU3VwcGx5IGFjdGl2aXRpZXMwCgYIKoZIzj0EAwIDSAAwRQIgOs5pumHtqBmp
GYcczA+Z+gGnLdqdoFXpM/RmN2OcBcUCIQDA931D6KZRQGsbLxzp0dd9TRDoVenL
VElB1UE+Vj/rMQ==
-----END CERTIFICATE REQUEST-----

Transformed it to JSON as follows:

{ “csr” : “MIICFjCCAbwCAQAwdTELMAkGA1UEBhMCU0ExFjAUBgNVBAsMDVJpeWFkaCBCcmFuY2gxJjAkBgNVBAoMHU1heGltdW0gU3BlZWQgVGVjaCBTdXBwbHkgTFREMSYwJAYDVQQDDB1UU1QtODg2NDMxMTQ1LTM5OTk5OTk5OTkwMDAwMzBWMBAGByqGSM49AgEGBSuBBAAKA0IABJle8IYEhvUv4v7+TVCwBk+IyVpvlFZj2V+l3yBAJqdcfpAngnHnKd7n2ojm6GE8GpuJGprmNuFJl7Dyt/Ft8KGggecwgeQGCSqGSIb3DQEJDjGB1jCB0zAhBgkrBgEEAYI3FAIEFAwSWkFUQ0EtQ29kZS1TaWduaW5nMIGtBgNVHREEgaUwgaKkgZ8wgZwxOzA5BgNVBAQMMjEtVFNUfDItVFNUfDMtZWQyMmYxZDgtZTZhMi0xMTE4LTliNTgtZDlhOGYxMWU0NDVmMR8wHQYKCZImiZPyLGQBAQwPMzk5OTk5OTk5OTAwMDAzMQ0wCwYDVQQMDAQxMTAwMREwDwYDVQQaDAhSUlJEMjkyOTEaMBgGA1UEDwwRU3VwcGx5IGFjdGl2aXRpZXMwCgYIKoZIzj0EAwIDSAAwRQIgOs5pumHtqBmpGYcczA+Z+gGnLdqdoFXpM/RmN2OcBcUCIQDA931D6KZRQGsbLxzp0dd9TRDoVenLVElB1UE+Vj/rMQ==” }

When I tried it on SandBox API, I got the following error:
Error: Bad Request
Response body:

can't parse JSON.  Raw result:

Invalid Request

Response Headers:

cache-control: no-store,max-age=0
content-type: application/json
expires: 0
pragma: no-cache
x-global-transaction-id: ae5a90e166f1d9cf4781024f

Q1: what am I doing wrong?
Q2: Is the csr-config correct? if not can you provide me with an example please?
Q3: Generating CSR this way is a right way to get the CSID?

Thank you in advance.

Dear @tsalama

Thanks for reaching out,

Please follow the below steps, and let me know if it works:

1- from your config file use this command "fatoora -csr -csrConfig “config file with the extension” ".
This command will generate encoded CSR and private Key.

2- Try the simulation Env as it’s a test Env, not the sandbox because the certificate in the sandbox is static, and this will cause you some errors when you signed your invoices,
Ensure that you have access to fatoora Simulation portal ( Zatca) you will find a box for “API Documentation” that will explain the APIs you need to follow in order to successfully onboarding your device.

Thanks,
Ibrahem Daoud.

Thank you @idaoud
I used both suggestions they helped me a lot.

Generated CSR in suggested step 1, worked fine with me on both sandbox (https://sandbox.zatca.gov.sa) and fatoora portal (https://fatoora.zatca.gov.sa/).

Regards,
Tony

Morning @tsalama

It’s great to hear that the issue was resolved, Thanks for your thanking me, it’s always a plusher to provide all needed help.

Thanks,
Ibrahem Daoud.

1 Like