---
title: "Explicit Request Contexts"
url: https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Explicit Request Contexts

Parts of this page are for some programming languages only, and name them. For one language's text alone, see [C++](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/matlab.md), [PHP](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/php.md), [Python](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/ruby.md), and [Swift](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts/swift.md).

Each proxy method that makes an invocation accepts a context parameter. A request context you pass through this parameter is an explicit context: it applies only to this invocation and [replaces the other contexts](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts.md#combining-request-contexts), even when it is empty. For example, a client asks for a French greeting:

> **C++**
>
> ```cpp
> string greeting = greeter->greet(name, {{"language", "fr"}});
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/cpp/Ice/context) provides a complete example.

> **C#**
>
> ```csharp
> string greeting = await greeter.GreetAsync(
>     name,
>     context: new Dictionary<string, string> { ["language"] = "fr" });
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/csharp/Ice/Context) provides a complete example.

> **Java**
>
> ```java
> String greeting = greeter.greet(name, Map.of("language", "fr"));
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/java/Ice/context) provides a complete example.

> **JavaScript**
>
> ```js
> const greeting = await greeter.greet(name, new Map([["language", "fr"]]));
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/js/Ice/context) provides a complete example.

> **MATLAB**
>
> ```matlab
> context = configureDictionary('string', 'string');
> context('language') = 'fr';
> greeting = greeter.greet(name, context);
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/matlab/Ice/context) provides a complete example.

> **PHP**
>
> ```php
> $context = ["language" => "fr"];
> $greeting = $greeter->greet($name, $context);
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/php/Ice/context) provides a complete example.

> **Python**
>
> ```py
> greeting = await greeter.greetAsync(name, context={"language": "fr"})
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/python/Ice/context) provides a complete example.

> **Ruby**
>
> ```ruby
> greeting = greeter.greet(name, {"language"=>"fr"})
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/ruby/Ice/context) provides a complete example.

> **Swift**
>
> ```swift
> let greeting = try await greeter.greet(name, context: ["language": "fr"])
> ```
>
> The [Ice context demo](https://github.com/zeroc-ice/ice-demos/tree/3.8/swift/Ice/Context) provides a complete example.
