gcloud auth activate-service-account --key-file $JSON_KEY_FILE
gcloud ai endpoints raw-predict $ENDPOINT_ID \
--project=$PROJECT_ID \
--region=$LOCATION_ID \
--http-headers=Content-Type=application/json \
--request=$JSON_BODY
gcloud auth activate-service-account --key-file $JSON_KEY_FILE
curl -X POST "https://$LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/$PROJECT_ID/locations/$LOCATION_ID/endpoints/$ENDPOINT_ID:rawPredict" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
--data $JSON_BODY
using Xunit;
using Google.Apis.Auth.OAuth2;
using Google.Protobuf;
using Google.Api;
using System.Threading.Tasks;
using Google.Cloud.AIPlatform.V1Beta1; // also tried just V1
namespace UnitTests;
public class UnitTest1
{
[Fact]
public async Task Test1()
{
var jsonKeyFile = "<path to json key file>";
var credential = GoogleCredential.FromFile(jsonKeyFile);
var client = await new PredictionServiceClientBuilder
{
Credential = credential,
}.BuildAsync();
var response = await client.RawPredictAsync( // error: 404
"projects/<project-id>/locations/<location-id>/endpoints/<endpoint-id>",
new HttpBody
{
Data = ByteString.CopyFromUtf8(@"<json body>")
});
}
}