Type float on JSON payload - Webhooks

Hello THere I am trying to send data to another applicatio trough webhooks
this is the JSON code:

{
      "name":"{{doc.product_name}}",
        "description": "{{doc.product_description | striptags |e }}",
        "track_inventory": true
    },
    "details": {
        "is_active": true,
        "product_codes": [{
            "code": "{{doc.product_sku}}"
        }],
        "price_including_tax": "{{'%0.2f'|format(doc.product_sell_price|float)}}"

    }
}

This is the actual JSON file.

{
 "common": {
  "description": "Velita muy bonita",
  "name": "Velita",
  "track_inventory": true
 },
 "details": {
  "is_active": true,
  "price_including_tax": "34.05",
  "product_codes": [
   {
    "code": "Vela-001"
   }
  ]
 }
}

The problem is that the remote app is expecting a float (34.05) and si receiving an string (“34.05”) there is any way in the JINJA templating to don’t use double qoutes??
I have seen something related on this post

You need to pass the value without a double quotation. For example, you have to pass the value
34.05 not “34.05”.

you can’t place a value without qoutes in that window. that is my question how do you do that? or if it is a bug?
Tried these:

  • “price_including_tax”: “{{‘%0.2f’|format(doc.product_sell_price|float)}}” this is allowed but the value is sent as string on qoutes
  • “price_including_tax”: {{doc.product_sell_price}} this is not allowed

Ideas?

Would you like to share the error?

First Thank you for even reading this post and spending time trying to help me
Here is the error:
obj = {‘error’: ‘Invalid data supplied’, ‘fields’: {‘price_including_tax’: ‘Invalid type. Expected: number, given: string’}}

I think I have not explain myself clearly on the to this is happening because the data on the field product_sell_price which is a number is being placed into the JSON files on quotes that is perceived as strign by the external app

In the wehook data window (JSON Request Body) is write like this. Is not allow to write it without the quotes

This is being converted from:
"price_including_tax": "{{doc.product_sell_price}}"

into the JSON file to:
"price_including_tax": "21.00" Note: quotes around the number

Which I need in the JSON file is this
"price_including_tax": 21.00 NO quotes around the number
I am looking to a way to place the dynamic field {{doc.product_sell_price}} inside the Webhook Data window without quotes.

Thanks

Leo

Anyone?

What is the error message exactly?


The correct way to send your Float data is indeed without quotes. But maybe the doc.product_sell_price expression is not always a number when Frappe checks your JSON body, for some reason?

The following might work:

{
   ...
  "price_including_tax": {{ doc.product_sell_price or 0.0 }}
}