DigitalOcean Functions: How to differentiate query params from body params?

I made a request with the following arguments:

  • Path: /test?potato=true
  • Body: { "banana": true }

In the event, I receive:

  "banana": true,
  "potato": "true",
  "__ow_method": "post",
  "__ow_headers": {
    "accept": "*/*",
    "accept-encoding": "gzip",
    "cdn-loop": "cloudflare",
    "cf-connecting-ip": "xx",
    "cf-ipcountry": "BR",
    "cf-ray": "xx",
    "cf-visitor": "{\"scheme\":\"https\"}",
    "content-type": "application/json",
    "host": "ccontroller",
    "user-agent": "insomnia/2022.4.2",
    "x-custom": "okay",
    "x-forwarded-for": "xx",
    "x-forwarded-proto": "https",
    "x-request-id": "xx"
  "__ow_path": ""

My question is: How do I differentiate a query param from a body param?

This way, it’s impossible to know if it’s a query param or a body param, except when the body is formatted in base64, in which case I get the body inside __ow_body.

Context: I’m a maintainer of serverless-adapter which integrates serverless clouds with any nodejs framework, I want to add support for Digital Ocean Functions to deploy apps like nestjs, trpc, etc.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 28, 2022
Accepted Answer

Hi there,

I’ve just checked this internally and when the directive web: raw is not set, the query and body params are promoted to first-class arguments. So you can’t distinguish them within your function.

There is a precedence order and if there are collisions, the body wins.

When the directive web: raw passes the query and body parameters are top-level arguments called __ow_query and _body.

The function then has to parse the query string on its own.

Hope that this helps!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel