Skip to content

Help - How to access request body in post request? #24

Description

@jhrdt

Hi,

Dump

POST /api/customer/show HTTP/1.1

HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": "${request.body}",
    "name": "Name"
}

Request

http localhost:9999/api/customer/show  id=1
POST /api/customer/show HTTP/1.1
Host: localhost:9999
User-Agent: HTTPie/1.0.3
Accept-Encoding: gzip, deflate
Accept: application/json, */*
Connection: keep-alive
Content-Type: application/json
Content-Length: 11

{"id": "1"}
--------------------------------------------------------------------------------
HTTP/1.1 200 OK
Content-Type: application/json
Server: DeepfakeHTTP v6.4.2 (2022-01-23 14:42:00)
Content-Length: 48
ETag: "85fffc49"

{
    "id": "{"id": "1"}",
    "name": "Name"
}

Expectation

Response:

{
    "id": "1",
    "name": "Name"
}

Question

What do I need to do, if I want to access the "id" key in the request body?

I tried "id": "${request.body.id}" but this returns "id": "undefined".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions