I’m receiving the error
ERRO[0002] unable to serialise request object to protocol buffer: proto: syntax error (line 1:47): unexpected token {
at go.k6.io/k6/js/common.Bind.func1 (native)
at file:///C:/Users/{myName}/repos/K6-Mach1/exchangeRateGrpc.js:43:130(46)
at native executor=constant-vus scenario=default source=stacktrace
- I can’t see any syntax errors in the proto file I’m using.
- When I switch to a different method, within the same service and proto file, the test runs correctly.
- The data I’m passing is valid JSON. I’ve swapped single quotes for double quotes and then for no quotes and back again but I’m still getting a syntax error.
- The params I’m passing work with a test of another proto file
import grpc from 'k6/net/grpc';
import { check, sleep } from 'k6';
import { Token } from './bearerToken.js';
const client = new grpc.Client();
client.load(['definitions'], 'Pollos-Hermanos.Contracts.v1.Services.PolloService.proto');
export default ()=> {
const token = Token().access_token;
const params = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
}
}
let serverURL = 'pollos.hermanos.io:3459';
client.connect(serverURL, {
plaintext: false
});
const data = { "ChickenCodes": [ "BAK", "BOK" ], "ExpireDate": { "seconds": "3638316800" }}
const response = client.invoke('Pollos-Hermanos.Contracts.v1.Services.PolloService.ChickenService/GetChickenRates', data, params);
check(response, {
'status is OK': (r) => r && r.status === grpc.StatusOK,
});
console.log(JSON.stringify(response.message));
client.close();
sleep(500);
};