I’m running a powershell script that uses the users-import job and then checks that job to see when it’s completed.
The users-import works fine, but when I invoke a rest GET call to ‘get a job’, I get an error:
statusCode: 400
message: Path validation error: \u0027String does not match pattern ^job_[A-Za-z0-9]{16}$: 7\u0027 on property id (ID of the job).
errorCode: invalid_uri
The command I’m using is Invoke-RestMethod -Method Get -Uri $request -Headers $headers
The URI I’m using is https://{tenantDomain}/api/v2/jobs/{#}
The Headers I’m using include the authorization:bearer token & accept:application/json
I’ve tried explicitly casting the # as an integer, but I get the same results.
I’m using this KB for reference and the URI isn’t overly complicated so I’m guessing I’m missing something else: docs/api/management/v2/jobs/get-jobs-by-id
Hi @ballop
Welcome to the Auth0 Community!
From the error that you are receiving, it appears that you are passing the wrong job_id
.
As mentioned in the documentation, the URL to retrieve a job would be https://{{auth0_domain}}/api/v2/jobs/{{job_id}}
.
May I ask why are you trying to cast the id as an integer? What is the exact job id that you are passing to the request? A usual job_id would look something like this:
job_132rCLeL6ap6Cb87
Could you also try the cURL command and let me know if it works fine or not?
curl -L 'https://{{auth0_domain}}/api/v2/jobs/{{job_id}}' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {{management_api_token}}'
Let me know if you have any other questions.
Kind Regards,
Nik
1 Like
That helped a ton, Nik thank you!!
It looks like my problem started with the users-import request. I threw the request into a variable, and the ID it came back with was a single digit, which is also why I attempted to cast it explicitly as an Integer. With the example you provided, I see where that’s in the Body of the response via Auth0 Logs, and so I’ll have to adjust my response variable to make sure I’m getting the full job string instead, and that should fix my issue.