Elad Winkler
Elad Winkler

Reputation: 700

HttpError 400 in jobs.get(jobId,ProjectId) even with right values

when I call jobs.get(jobId,ProjectID); I get:

"code" : 400, "errors" : [ { "domain" : "global", "message" : "Invalid project ID 'My_Project_ID:job_6c2e8cc358ad42d2ad55ef266d342b68'. Project IDs must contain 6-63 lowercase letters, digits, or dashes. IDs must start with a letter and may not end with a dash.", "reason" : "invalid" } ], "message" : "Invalid project ID 'My_Project_ID:job_6c2e8cc358ad42d2ad55ef266d342b68'. Project IDs must contain 6-63 lowercase letters, digits, or dashes. IDs must start with a letter and may not end with a dash."

(I switched projectId with "My_Project_ID")

If I use the exact projectID and jobID in the "try it" section in the google developer guide in here

I get the job back as expected!

If projectId or jobId wasn't right then it wouldn't have worked in the google developer site also. What can cause this behavior?

Upvotes: 1

Views: 1023

Answers (2)

Alex
Alex

Reputation: 977

I had this problem when trying to do following:

jobs().get(projectId, job.getId()).execute().getStatus().getState();

Seems like job.getId() returns a String which contains both ProjectId and JobId (and contains characters which are not allowed in Job-Ids). The solution is to call job.getJobReference().getJobId() instead.

jobs().get(projectId, job.getJobReference().getJobId()).execute().getStatus().getState();

Upvotes: 0

Jeremy Condit
Jeremy Condit

Reputation: 7046

It looks like you're passing the fully-qualified job ID as the project ID. In the example you mentioned above, "My_Project_ID" is the project ID and "job_6c2e8cc358ad42d2ad55ef266d342b68" is the job ID, but it looks like you're passing the full string "My_Project_ID:job_6c2e8cc358ad42d2ad55ef266d342b68" as the job ID.

Note also that the parameter order is (projectId, jobId), not (jobId, projectId).

Try calling jobs.get("My_Project_ID", "job_6c2e8cc358ad42d2ad55ef266d342b68"), and see if that works.

Upvotes: 2

Related Questions