---
title: "Client.invoke(url, request [,params]) | Grafana k6 documentation"
description: "Invokes an unary RPC request to the given method."
---

# Client.invoke(url, request \[,params])

Invokes an unary RPC request to the given method.

The given method to invoke must have its RPC schema previously loaded via the [Client.load()](/docs/k6/latest/javascript-api/k6-net-grpc/client/client-load/) function, otherwise an error will be thrown.

[Client.connect()](/docs/k6/latest/javascript-api/k6-net-grpc/client/client-connect/) must be called first before invoking a request, otherwise an error will be thrown.

Expand table

| Parameter         | Type   | Description                                                                                                                                                                 |
|-------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| url               | string | The gRPC method URL to invoke, in the form `/package.Service/Method`, e.g. `/google.cloud.language.v1.LanguageService/AnalyzeSentiment`. The leading slash `/` is optional. |
| request           | object | The canonical request object, as-per the [Protobuf JSON Mapping](/docs/k6/latest/using-k6/protocols/grpc/#protocol-buffers-json-mapping).                                   |
| params (optional) | object | [Params](/docs/k6/latest/javascript-api/k6-net-grpc/params/) object containing additional request parameters.                                                               |

### Returns

Expand table

| Type       | Description                                                                   |
|------------|-------------------------------------------------------------------------------|
| `Response` | gRPC [Response](/docs/k6/latest/javascript-api/k6-net-grpc/response/) object. |

### Examples

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import grpc from 'k6/net/grpc';
import { check } from 'k6';

const client = new grpc.Client();
client.load([], 'routeguide.proto');

export default () => {
  client.connect('localhost:10000', { plaintext: true });
  const response = client.invoke('main.RouteGuide/GetFeature', {
    latitude: 410248224,
    longitude: -747127767,
  });
  check(response, { 'status is OK': (r) => r && r.status === grpc.StatusOK });
  console.log(response.message.name);
  // output: 3 Hasta Way, Newton, NJ 07860, USA

  client.close();
};
```
