Back

Functions: error trying to retrieve request body (Python runtime)

  • 0
  • Functions
  • REST API
  • Cloud
Fede_
30 Aug, 2024, 10:41

Hi i'm writing a python functions and i need to retrieve request body.

Server: Appwrite cloud. CLI: 6.0.0 The Functions is in local dev with Appwrite CLI.

I find this code snippet in functions doc:

TypeScript
import json

def main(context):
    context.log(context.req.bodyText)              # Raw request body, contains request data

(Source: https://appwrite.io/docs/products/functions/develop#request)

but if i try it, i receive:

TypeScript
context.log(context.req.bodyRaw)              # Raw request body, contains request data
AttributeError: 'Request' object has no attribute 'bodyRaw'

This is Postman body view:

TL;DR
Developers are encountering errors trying to retrieve the request body in Python runtime using the Appwrite CLI. The issue seems to stem from version incompatibilities between the local development CLI (version 6.0.0) and the Appwrite cloud version (1.5.10). The solution provided is to use `req.bodyRaw` instead of the deprecated `req.bodyText`. Appwrite cloud is still on version 1.5.10 while the documentation references version 1.6.x.
darShan
30 Aug, 2024, 10:43

Use req.bodyRaw, Cloud is still on 1.5.10 while the docs point to the 1.6.x release.

darShan
30 Aug, 2024, 10:47

basically use the deprecated methods on cloud.

Fede_
30 Aug, 2024, 10:49

I had tried with the previous version but:

Fede_
30 Aug, 2024, 10:50

where:

TypeScript
req = context.req
context.log(req.bodyRaw)
darShan
30 Aug, 2024, 10:55

You seem to be using the CLI local development, I don't think it might be compatible with 1.5.10. @Meldiron is it though?

Fede_
30 Aug, 2024, 10:59

Yes, I am using local CLI development to test the function before loading it. I didn't find anything in the doc about version incompatibilities :appwritemandancing:

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more