Issue with Invocation to Python Services in Dapr

Mhd Issa 0 Reputation points
2025-01-13T17:17:41.02+00:00

Dear Microsoft Dapr Support Team,

I hope this message finds you well.

I am encountering an issue when attempting to invoke Python services using Dapr. The following error is appearing:

java
Copy code
code 

Upon investigating, it seems this error occurs when order information is incomplete or missing. However, despite extensive attempts to resolve this, including referencing the official Dapr documentation and implementing the sample code provided, the error persists.

As a temporary workaround, I am routing the request through a gateway, but this is not a viable long-term solution. I plan to revisit this issue after addressing higher-priority tasks and bugs.

Could you provide any insights or guidance on the root cause and how to resolve this issue? Your support would be greatly appreciated.

this is my code :

with DaprClient() as d:
            #last_headers = [("invoker-app-id", "filemanagement"),("data","data")]
            if method.lower() == "get":
                response = d.invoke_method(
                    appid,
                    path,
                    data='{"message":"Hello World"}',
                    metadata=None,
                    content_type="application/json",
                )
            else:
                response = d.invoke_method(
                    appid, path, data=payload, metadata=None, http_verb="post"
                )

and this is the view that i received the invoke :

class Test1(APIView):
    parser_classes = [JSONParser]
    def post(self, request, *args, **kwargs):
                print(request.data)

but the request.data is empty

Thank you in advance for your assistance.

Best regards, Mhd Issa

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,257 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,318 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,224 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,158 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Walter Coan 150 Reputation points MVP
    2025-01-13T23:54:28.6666667+00:00

    Hi Mhd Issa,

    I think the problem is because in your first call of the invoke_method you don't define the HTTP Method POST, and the default value for Dapr SDK is to do a GET. https://github.com/dapr/python-sdk/blob/0f6e96a3164b5cdbc3ca8888fa60e5729b3e8a4e/dapr/clients/http/dapr_invocation_http_client.py#L82

    I hope this help you.

    Walter


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.