Reputation: 11
We are trying to call the Google.Cloud.AIPlatform.V1 predict API using the .Net client and keep getting the following error: Received http2 header with status: 404
We setup credentials using the API key and environment variable: GOOGLE_APPLICATION_CREDENTIALS
Here is the code to call the vertex AI predict API:
const string projectId = "xxxxxx";
const string location = "us-central1";
const string endpointId = "xxxxxx";
PredictionServiceClient client = PredictionServiceClient.Create();
var structVal = Google.Protobuf.WellKnownTypes.Value.ForStruct(new Struct
{
Fields =
{
["mimeType"] = Google.Protobuf.WellKnownTypes.Value.ForString("text/plain"),
// Sample contents is a string constant defined in a separate file
["content"] = Google.Protobuf.WellKnownTypes.Value.ForString(Consts.SampleContents)
}
});
PredictRequest req = new PredictRequest()
{
EndpointAsEndpointName = EndpointName.FromProjectLocationEndpoint(projectId, location, endpointId),
Instances = { structVal }
};
PredictResponse response = client.Predict(req);
The full error returned:
Status(StatusCode="Unimplemented", Detail="Received http2 header with status: 404", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1644947338.412000000","description":"Received http2 :status header with non-200 OK status","file":"......\src\core\ext\filters\http\client\http_client_filter.cc","file_line":134,"grpc_message":"Received http2 header with status: 404","grpc_status":12,"value":"404"}")
I validate the same call using CURL and was able to successfully make the call.
curl -X POST -H "Authorization: Bearer XXXXX" -H "Content-Type: application/json" https://us-central1-aiplatform.googleapis.com/ui/projects/XXXXXX/locations/us-central1/endpoints/XXXXXX:predict -d @payload.json
Any help would be greatly appreciated.
Upvotes: 1
Views: 1666
Reputation: 31
I think, we had same problem and I was resolve that
PredictionServiceClient -> Need EndPoint of PredictionServiceClient Set,
PredictionServiceClient client = PredictionServiceClient.Create();
change please
PredictionServiceClientBuilder ClientBuilder = new PredictionServiceClientBuilder();
ClientBuilder .Endpoint = "us-central1-aiplatform.googleapis.com";
PredictionServiceClient client = ClientBuilder.Build();
thanks
Upvotes: 3