I am getting the following response from calling BigQuery REST API from Apigee:
{"error":{"code":404,"message":"Request couldn't be served.",
"errors":[{"message":"Request couldn't be served.","domain":"global","reason":"notFound"}],"status":"NOT_FOUND"}}
This is what I have to build the query payload and target endpoint flow:
Assign message policy: AM-BuildCalendarQuery
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-BuildCalendarQuery">
<DisplayName>AM-BuildCalendarQuery</DisplayName>
<Properties/>
<Set>
<Verb>GET</Verb>
<Payload contentType="application/json">
{
"kind": "bigquery#queryRequest",
"query": "SELECT SUBSTR(CAL_ID,6,3) as state,formatted_date, FORMAT_DATE('%Y', formatted_date) as year ,
FORMAT_DATE('%Q', formatted_date) as quarter
FROM `<my-project-id>.TestDataset.calendar_vw` where CAL_ID like 'A24AU%'
and FORMAT_DATE('%Y', formatted_date) = '2024' order by state, formatted_date asc",
"defaultDataset": {
"datasetId": "TestDataset",
"projectId": "<my-project-id>"
},
"useQueryCache": true,
"useLegacySql": false,
"location": "australia-southeast1",
"timeoutMs": 60000
}
</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
And the target endpoint flow:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<Flows/>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<HTTPTargetConnection>
<Authentication>
<GoogleAccessToken>
<Scopes>
<Scope>https://www.googleapis.com/auth/cloud-platform</Scope>
</Scopes>
<LifetimeInSeconds ref="{variable}">3600</LifetimeInSeconds>
</GoogleAccessToken>
</Authentication>
<SSLInfo>
<Enabled>true</Enabled>
<IgnoreValidationErrors>true</IgnoreValidationErrors>
</SSLInfo>
<URL>https://bigquery.googleapis.com/bigquery/v2/projects/<my-project-id>/queries</URL>
</HTTPTargetConnection>
</TargetEndpoint>
I ran the same request payload and target endpoint URL on https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query and it returns the resultset successfully.
So what does this "404 Request couldn't be served" mean? I couldn't find any info from the google site. Could it be a permission issue?