> For the complete documentation index, see [llms.txt](https://www.learnros2.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.learnros2.com/ros/cookbook/how-to-inspect-service-and-make-a-service-call.md).

# How to inspect service and make a service call

In this article, we will walk through the process of service inspection and present an example of making service call.

The first step is to list available services on the network

```
ros2 service list
ros2 service list -t
```

The second command list both service name and the request type.

Suppose we have a service called `/add_entity`. The next step is to find out the reques type of this service. This can be done using the following command:

```
ros2 service type /add_entity
```

The output of this command is the service request type. Suppose the output is `entity_management/srv/AddEntity`. The next step is to find out the details of this type. This can be done using the following command:

```
ros2 interface show entity_management/srv/AddEntity
```

The `interface show` command produces the details of the type. For example,&#x20;

```
AddEntity
string name
string model_filepath
geometry_msgs/Point location
	float64 x
	float64 y
	float64 z
float64 theta
---
bool result
```

To summarize, we have collected the following information:

| Item                        | Description                            |
| --------------------------- | -------------------------------------- |
| service name                | /add\_entity                           |
| service request type        | entity\_management/srv/AddEntity       |
| service response type       | bool                                   |
| fields in the request  type | name, model\_filepath, location, theta |

The remaining question is how can we make a service call? The command to use is `ros2 service call <service_name> <service_type>`. Here is an example:

{% code overflow="wrap" %}

```
ros2 service call /add_entity entity_management/srv/AddEntity "{name: 'name with space', model_filepath: 'test_path', location: {x: 1, y: 2, z: 3}, theta: 1.3}"
```

{% endcode %}

{% hint style="warning" %}
The space in the command is significant, especially the one following the colon (:) that comes after the field name.
{% endhint %}

©2023 - 2024 all rights reserved


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.learnros2.com/ros/cookbook/how-to-inspect-service-and-make-a-service-call.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
