I have a problem with my AutoML code. I want to link it to a web project. I've used the Google tutorial but it doesn't work. I receive this error in my console :
payload : { row:
{ values:
[ [Object], [Object], [Object], [Object], [Object], [Object] ] } }
{ Error: 3 INVALID_ARGUMENT: Request contains an invalid argument.
at Object.callErrorFromStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call.js:30:26)
at Object.onReceiveStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\client.js:175:52)
at Object.onReceiveStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\client-interceptors.js:341:141)
at Object.onReceiveStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\client-interceptors.js:304:181)
at Http2CallStream.outputStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call-stream.js:116:74)
at Http2CallStream.maybeOutputStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call-stream.js:155:22)
at Http2CallStream.endCall (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call-stream.js:141:18)
at Http2CallStream.handleTrailers (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call-stream.js:273:14)
at ClientHttp2Stream.emit (events.js:198:13)
at emit (internal/http2/core.js:265:8)
code: 3,
details: 'Request contains an invalid argument.',
metadata:
Metadata {
internalRepr: Map { 'grpc-server-stats-bin' => [Array] },
options: {} } }
Error: 3 INVALID_ARGUMENT: Request contains an invalid argument.
My code looks like this
It Comes from this github repo
I've created the JSON credentials to use my ML code to website
On this project, I use Express (i've deleted the code for you)
// ========================================
// Config modules
// ========================================
const clientOptions = {
apiEndpoint: 'eu-automl.googleapis.com'
};
const client = new automl.v1beta1.PredictionServiceClient(clientOptions);
// =======================================
// Function for api route
// =======================================
const projectId = '*****'; // Project ID from GCP
const computeRegion = 'eu'; // eu (like my bucket)
const modelId = '******'; // modelID from my CGP Table ML
const modelFullId = client.modelPath(projectId, computeRegion, modelId);
console.log("modelFullId :", modelFullId)
const sendDataPredict = async (data) => {
let values = [];
for (const val in data) {
values.push({
[typeof val == 'string' ? 'stringValue' : 'numberValue']: val
});
}
const payload = {
row: {
values: values
},
};
I've tried with Postman but i have the same error. Many thanks for all your help
Try to use this:
const clientOptions = {
apiEndpoint: 'eu-automl.googleapis.com',
port: '443'
};