Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support to render object #2233

Open
NingGelin opened this issue Dec 7, 2023 · 6 comments
Open

support to render object #2233

NingGelin opened this issue Dec 7, 2023 · 6 comments
Labels
enhancement New feature or request topic: template

Comments

@NingGelin
Copy link

Problem to solve

my hurl file

POST {{host}}/partyManagement/v5/individual
{
  "@type": "Individual",
  "@baseType": "Party",
  "givenName": "Jane-us0001-ac1-{{postfix}}",
  "familyName": "Lamborgizzia-us0001-ac1-{{postfix}}"
}
HTTP 201
[Captures]
response: jsonpath "$"

POST {{host}}/customerManagement/v5/customer
{{response}}
HTTP 201

Proposal

I want to extract a object from response last step then render it in next step. It seem like not supported currently. If I missed something, please correct me. Thank you very much.

Additional context and resources

@NingGelin NingGelin added the enhancement New feature or request label Dec 7, 2023
@fabricereix
Copy link
Collaborator

Hi @NingGelin
yes this is not supported yet.
you can have a look at #2152

@jcamiel
Copy link
Collaborator

jcamiel commented Dec 7, 2023

In this particular use case (you want to render the full body), you can also capture the full body (which has a text type)

POST {{host}}/partyManagement/v5/individual
{
  "@type": "Individual",
  "@baseType": "Party",
  "givenName": "Jane-us0001-ac1-{{postfix}}",
  "familyName": "Lamborgizzia-us0001-ac1-{{postfix}}"
}
HTTP 201
[Captures]
response: body

POST {{host}}/customerManagement/v5/customer
{{response}}
HTTP 201

It "should" work (I've not tested it)

@NingGelin
Copy link
Author

In this particular use case (you want to render the full body), you can also capture the full body (which has a text type)

POST {{host}}/partyManagement/v5/individual
{
  "@type": "Individual",
  "@baseType": "Party",
  "givenName": "Jane-us0001-ac1-{{postfix}}",
  "familyName": "Lamborgizzia-us0001-ac1-{{postfix}}"
}
HTTP 201
[Captures]
response: body

POST {{host}}/customerManagement/v5/customer
{{response}}
HTTP 201

It "should" work (I've not tested it)

not work. thank you anyway

@jcamiel
Copy link
Collaborator

jcamiel commented Dec 13, 2023

Ah sorry @NingGelin , you can use multiline string body, that should do the trick. You can put a hint with the json tag to send the right application/json Content-Type header:

POST {{host}}/partyManagement/v5/individual
{
  "@type": "Individual",
  "@baseType": "Party",
  "givenName": "Jane-us0001-ac1-{{postfix}}",
  "familyName": "Lamborgizzia-us0001-ac1-{{postfix}}"
}
HTTP 201
[Captures]
response: body

POST {{host}}/customerManagement/v5/customer
```json
{{response}}
```
HTTP 201

@juan-m-medina
Copy link

juan-m-medina commented May 14, 2024

Ah sorry @NingGelin , you can use multiline string body, that should do the trick. You can put a hint with the json tag to send the right application/json Content-Type header:

POST {{host}}/partyManagement/v5/individual
{
  "@type": "Individual",
  "@baseType": "Party",
  "givenName": "Jane-us0001-ac1-{{postfix}}",
  "familyName": "Lamborgizzia-us0001-ac1-{{postfix}}"
}
HTTP 201
[Captures]
response: body

POST {{host}}/customerManagement/v5/customer
```json
{{response}}

HTTP 201

While this works for the full body, it won't work for a jsonpath extract - with or without the multi-line hint.

GET https://jsonplaceholder.typicode.com/posts

HTTP 200
[Captures]
first_post: jsonpath "$[0]"

PUT https://jsonplaceholder.typicode.com/posts/1
{{first_post}}
HTTP 200
image

@jcamiel
Copy link
Collaborator

jcamiel commented May 14, 2024

Hi @juan-m-medina

Rendering a variable captured by JSONPath query (like {{first_post}}) is not yet supported. As a workaround until a proper solution is implemented, you can split your captures :

GET https://jsonplaceholder.typicode.com/posts
HTTP 200
[Captures]
first_post_name: jsonpath "$[0].name"
first_post_description: jsonpath "$[0].description"
first_post_publication_date: jsonpath "$[0].publication_date"


PUT https://jsonplaceholder.typicode.com/posts/1
{ 
  "name:" {{first_post_name}},
  "description": {{first_post_description}},
  "publication_date": {{first_post_publication_date}}
}
HTTP 200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic: template
Projects
None yet
Development

No branches or pull requests

4 participants