Same JSON paste to Define API Schema for Global Input Variables

When working with many webhook services, to first test the return I might use something like webhook.site, beeceptor.com, postman, which will show me the entire JSON payload response from whichever API provider is sending me a webhook.

Would it be possible to use a similar system to Define API Schema to copy / paste that response into the server actions global input variable for $_POST.
In fact it would even be handy if that same Define API Schema paste mechanism could be used in normal Set Value Array Define Schema steps too.

I know Wappler loves adding new features and this would be a nice little speed boost, instead of adding the entire structure manually.

On a side note, i know there is no real NEED to add the Global Input Variables, and they can still be used without defining them, but it makes it easier to use the pickers if they are there.

You could do the edits by copying/pasting directly into the JSON editor. Much quicker than doing it ny hand

Sorry, not too sure what you mean? There is no JSON editor available for Global Input Variables, only for an API Action Define API Schema.

I ask an API provider to send me a webhook each time a product is updated as an example, they send a webhook JSON payload like this.

{
  "productType": "ACTIVITY",
  "name": "Paul Test Product 11-10-2012",
  "shortDescription": "This is just a little test for a new product",
  "description": "This is a test from Paul for when a new product is added to Rezdy to see how the webhook fires so it can populate our internal data sets.",
  "productCode": "PMG9JN",
  "internalCode": "",
  "timezone": "Europe/Oslo",
  "advertisedPrice": "600.0",
  "priceOptions": [
    {
      "price": "600.0",
      "label": "Adult",
      "seatsUsed": 1,
      "minQuantity": 0,
      "priceGroupType": "EACH"
    },
    {
      "price": "400.0",
      "label": "Child",
      "seatsUsed": 1,
      "minQuantity": 0,
      "priceGroupType": "EACH"
    },
    {
      "price": "0.0",
      "label": "Infant",
      "seatsUsed": 1,
      "minQuantity": 0,
      "priceGroupType": "EACH"
    }
  ],
  "currency": "NOK",
  "unitLabel": "Participant",
  "unitLabelPlural": "Participants",
  "quantityRequired": true,
  "quantityRequiredMin": 1,
  "quantityRequiredMax": 16,
  "bookingMode": "DATE_ENQUIRY",
  "charter": false,
  "extras": [
    {
      "name": "Beer ",
      "description": "Beer onboard the boat, NOK 60",
      "price": "60.0",
      "extraPriceType": "ANY"
    },
    {
      "name": "Bottle of Moet",
      "description": "Bottle of Moet",
      "price": "1290.0",
      "extraPriceType": "ANY"
    },
    {
      "name": "Catered lunch",
      "description": "Catered lunch",
      "price": "155.0",
      "extraPriceType": "ANY"
    }
  ],
  "bookingFields": [
    {
      "label": "First Name",
      "requiredPerParticipant": false,
      "requiredPerBooking": true,
      "visiblePerParticipant": true,
      "visiblePerBooking": true,
      "fieldType": "FIRSTNAME"
    },
    {
      "label": "Last Name",
      "requiredPerParticipant": false,
      "requiredPerBooking": true,
      "visiblePerParticipant": true,
      "visiblePerBooking": true,
      "fieldType": "LASTNAME"
    },
    {
      "label": "Mobile",
      "requiredPerParticipant": false,
      "requiredPerBooking": true,
      "visiblePerParticipant": false,
      "visiblePerBooking": true,
      "fieldType": "MOBILE"
    },
    {
      "label": "Email",
      "requiredPerParticipant": false,
      "requiredPerBooking": true,
      "visiblePerParticipant": false,
      "visiblePerBooking": true,
      "fieldType": "EMAIL"
    },
    {
      "label": "Country",
      "requiredPerParticipant": false,
      "requiredPerBooking": false,
      "visiblePerParticipant": false,
      "visiblePerBooking": true,
      "fieldType": "COUNTRY"
    },
    {
      "label": "Special Requirements",
      "requiredPerParticipant": false,
      "requiredPerBooking": false,
      "visiblePerParticipant": false,
      "visiblePerBooking": true,
      "fieldType": "SPECIALREQS"
    }
  ],
  "confirmMode": "AUTOCONFIRM",
  "confirmModeMinParticipants": 0,
  "dateCreated": "2021-10-11T10:32:17Z",
  "minimumNoticeMinutes": 60,
  "durationMinutes": 120,
  "dateUpdated": "2021-10-12T08:37:08Z",
  "locationAddress": {
    "addressLine": "Kirkegata 1",
    "city": "TROMSØ",
    "countryCode": "no",
    "latitude": 69.6481675,
    "longitude": 18.960806899999966,
    "postCode": "9008",
    "state": "Troms"
  },
  "languages": [
    "en_us"
  ],
  "waitListingEnabled": false,
  "barcodeOutputType": "ORDER"
}

Now back in Wappler I want to make a script to receive this payload and use various parts of it or possibly all of it. Currently I have to open Input, $_POST, and create a Variable OR Array OR Object manually and give it the exact same name as what i want returned.

The only way I can manually do it is to open the server action in Wapplers editor and add paste the payload and edit each part to include its name and type assignments and set to object or array etc.

Unless you mean paste the JSON response in the Define API Schema window and press OK, then open the script in the editor and copy out the meta data it created. Which is what i sometimes do.

That’s what I meant “paste the JSON response in the Define API Schema…” - it’s a little faster than manually typing them. I usually just store them as an object without a schema and then refererence the fields <>.manually - which has the disadvantage that they’re not included in pickers - but I gave up on pickers, etc… generally for the reason outlined…

I think we are getting muddled up with two completely different things here.

If I want to CALL an API, I add an API action, I click Define API Schema, and paste in the JSON payload which populates all the fields I need.
That is perfect and works wonderfully.

In my question, I am not even adding an API step at all, I am not calling an API, the webhook is calling me, not the other way around, and I need to do something with this random payload they are sending me, so I can write its response into my database.

My server action will not have any API action, but instead have Global Input Variables only, which have no way of pasting a JSON payload to populate, here is a sample one.
2021-10-15_13-24-58

The webhook sends me a massive payload, one of the elements of the payload is productCode which I use to do some database actions. As you can see there is no Api Step in the server action at all.

My Feature request is for Wappler to take the exact same functionality we already have in the API Action step for Define API Schema, and duplicate it so I can also use it to populate the Global Input Variables.

Yes, I understand. In this scenario, I simply don’t bother defining most callback content in detail. I simply reference the fields as they exist

I see, so I think this feature could help you too in this sort of case. It would make life a little simpler than all the manual callbacks, obviously in situations like my example where I only need one variable returned its not a massive deal, but some of my actions are getting pretty heavy with their returns, and its a real pain calling them manually or adding all the input vars manually.

1 Like

Agreed.

1 Like

This would be a great option.
Similar to import from form, there could be an option to import from Schema.
For Set Value schema, same UI as API Action step could work.

Here’s what I do for now.

  1. Add a dummy api action and set the to be used schema from beeceptor or postman there.
  2. In set value or POST input, create 2 dummy variables. Two because it creates an array in code.
  3. Save and open the server action in code view, locate the API action and copy the META json.
  4. Paste this JSON as is in POST or in meta of set value.

Works perfectly. Similar to copy/pasting JSON steps from SA to a library SA. :sweat_smile:

1 Like

Yup, im doing something similar, but have to admit, the reason I even asked the question here was because I broke a server action so bad I had to recreate it because I could not figure out what I did wrong, haha, I think I may have pasted a bracket too many or something.

Would be great if it was built in so I could avoid breaking things.

1 Like