public async Task InvokeMethodAsync()

in src/Microsoft.Azure.WebJobs.Extensions.Dapr/Services/DaprServiceClient.cs [149:186]


        public async Task InvokeMethodAsync(
            string? daprAddress,
            string appId,
            string methodName,
            string httpVerb,
            object? body,
            CancellationToken cancellationToken)
        {
            try
            {
                this.EnsureDaprAddress(ref daprAddress);

                var req = new HttpRequestMessage(new HttpMethod(httpVerb), $"{daprAddress}/v1.0/invoke/{appId}/method/{methodName}");
                if (body != null)
                {
                    req.Content = new StringContent(
                        JsonSerializer.Serialize(body, JsonUtils.DefaultSerializerOptions),
                        Encoding.UTF8,
                        "application/json");
                    req.Content.Headers.ContentType.CharSet = string.Empty;
                }

                await this.daprClient.SendAsync(this.invokeOutputLogger, req, cancellationToken);
            }
            catch (JsonException ex)
            {
                throw new DaprException(HttpStatusCode.BadRequest, ErrorCodes.ErrDaprBadRequest, "Failed to serialize. Reason: " + ex.Message, ex);
            }
            catch (Exception ex)
            {
                if (ex is DaprException || ex is DaprSidecarNotPresentException)
                {
                    throw;
                }

                throw new DaprException(HttpStatusCode.InternalServerError, ErrorCodes.ErrDaprRequestFailed, "An error occurred while invoking method.", ex);
            }
        }