Last active
March 30, 2020 20:50
-
-
Save decentration/772a1c75c734fbef4205a1801b0ac77b to your computer and use it in GitHub Desktop.
Beans API configuration, POST and response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const options = { | |
url: 'https://api.knack.com/v1/objects/object_28/records', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json', | |
'X-KNACK-APPLICATION-ID': bundle.authData.Knack-Application-Id , | |
'X-KNACK-REST-API-KEY': bundle.authData.Knack-REST-API-KEY | |
}, | |
params: { | |
'Knack-Application-Id ': bundle.authData.Knack-Application-Id , | |
'Knack-REST-API-KEY': bundle.authData.Knack-REST-API-KEY, | |
'content-type': 'application/json' | |
}, | |
body: { | |
'field_358': bundle.inputData.field_358, | |
'field_226': bundle.inputData.field_226, | |
'field_314': bundle.inputData.field_314, | |
'field_261': bundle.inputData.field_261, | |
'field_271': bundle.inputData.field_271, | |
'field_272': bundle.inputData.field_272, | |
'field_273': bundle.inputData.field_273, | |
'field_277': bundle.inputData.field_277, | |
'field_278': bundle.inputData.field_278, | |
'field_281': bundle.inputData.field_281, | |
'field_282': bundle.inputData.field_282, | |
'field_351': bundle.inputData.field_351, | |
'field_352': bundle.inputData.field_352, | |
'field_354': bundle.inputData.field_354 | |
} | |
} | |
return z.request(options) | |
.then((response) => { | |
response.throwForStatus(); | |
const results = z.JSON.parse(response.content); | |
// You can do any parsing you need for results here before returning them | |
return results; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"inputData": { | |
"field_358": "jimjones@myself.com", | |
"field_226": "4000", | |
"field_314": "GBP", | |
"field_261": "Services rendered...", | |
"field_271": "Google Ireland", | |
"field_272": "28/06/2020", | |
"field_273": "", | |
"field_277": "Irene Slade", | |
"field_278": "ireneslade@google.com", | |
"field_281": "+447777123456", | |
"field_282": "yes", | |
"field_351": "yes", | |
"field_352": "yes", | |
"field_354": "yes" | |
}, | |
"authData": {}, | |
"environment": {}, | |
"subscribeData": {}, | |
"cleanedRequest": { | |
"url": "https://example.com/hook-request-origin", | |
"method": "POST", | |
"body": {}, | |
"headers": { | |
"Content-Type": "application/json" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "5e8259d1e665d90015b9ef67", | |
"field_244": 224, | |
"field_244_raw": 224, | |
"field_230": "30/03/2020 8:42pm", | |
"field_230_raw": { | |
"date": "03/30/2020", | |
"date_formatted": "30/03/2020", | |
"hours": "08", | |
"minutes": "42", | |
"am_pm": "PM", | |
"unix_timestamp": 1585600920000, | |
"iso_timestamp": "2020-03-30T20:42:00.000Z", | |
"timestamp": "03/30/2020 08:42 pm", | |
"time": 1242 | |
}, | |
"field_226": "£4000.00", | |
"field_226_raw": 4000, | |
"field_232": "No", | |
"field_232_raw": false, | |
"field_253": "", | |
"field_255": "Pending verifications", | |
"field_255_raw": "Pending verifications", | |
"field_259": "No", | |
"field_259_raw": false, | |
"field_261": "Services rendered...", | |
"field_261_raw": "Services rendered...", | |
"field_266": 0, | |
"field_266_raw": 0, | |
"field_267": 0, | |
"field_267_raw": 0, | |
"field_271": "Google Ireland", | |
"field_271_raw": "Google Ireland", | |
"field_272": "27/06/2020", | |
"field_272_raw": { | |
"date": "06/27/2020", | |
"date_formatted": "27/06/2020", | |
"hours": "12", | |
"minutes": "00", | |
"am_pm": "AM", | |
"unix_timestamp": 1593216000000, | |
"iso_timestamp": "2020-06-27T00:00:00.000Z", | |
"timestamp": "06/27/2020 12:00 am", | |
"time": 1380 | |
}, | |
"field_275": "£3900.00", | |
"field_275_raw": 3900, | |
"field_277": "Irene Slade", | |
"field_277_raw": "Irene Slade", | |
"field_278": "<a href=\"mailto:ireneslade@google.com\">ireneslade@google.com</a>", | |
"field_278_raw": { | |
"label": "ireneslade@google.com", | |
"email": "ireneslade@google.com" | |
}, | |
"field_281": "<a href=\"tel:+447777123456\">+447777123456</a>", | |
"field_281_raw": { | |
"full": "+447777123456", | |
"number": "+447777123456", | |
"formatted": "+447777123456" | |
}, | |
"field_303": "No", | |
"field_303_raw": false, | |
"field_314": "GBP", | |
"field_314_raw": "GBP", | |
"field_316": 0, | |
"field_316_raw": 0, | |
"field_276": "not yet", | |
"field_276_raw": "not yet", | |
"field_282": "Yes", | |
"field_282_raw": true, | |
"field_351": "Yes", | |
"field_351_raw": true, | |
"field_352": "Yes", | |
"field_352_raw": true, | |
"field_354": "Yes", | |
"field_354_raw": true, | |
"field_358": "<a href=\"mailto:jimjones@myself.com\">jimjones@myself.com</a>", | |
"field_358_raw": { | |
"email": "jimjones@myself.com" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "5e8256e5d535280015a38de1", | |
"account_status": "active", | |
"approval_status": "approved", | |
"profile_keys": "User Account", | |
"profile_keys_raw": [ | |
{ | |
"id": "profile_5", | |
"identifier": "User Account" | |
} | |
], | |
"field_151": 9000055, | |
"field_151_raw": 9000055, | |
"field_13": "Ramsey Ajram", | |
"field_13_raw": { | |
"last": "Ajram", | |
"first": "Ramsey" | |
}, | |
"field_14": "<a href=\"mailto:ramajr@foweh.com\">ramajr@foweh.com</a>", | |
"field_14_raw": { | |
"label": "ramajr@foweh.com", | |
"email": "ramajr@foweh.com" | |
}, | |
"field_15": "*********", | |
"field_15_raw": "**********", | |
"field_16": "active", | |
"field_16_raw": "active", | |
"field_17": "<span class=\"profile_5\">User Account</span>", | |
"field_17_raw": [ | |
"profile_5" | |
], | |
"field_133": "", | |
"field_175": 55, | |
"field_175_raw": 55, | |
"field_199": "", | |
"field_200": "", | |
"field_262": 2175, | |
"field_262_raw": 2175, | |
"field_264": "", | |
"field_336": "", | |
"field_355": "No", | |
"field_355_raw": false, | |
"field_356": 2175, | |
"field_356_raw": 2175 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const options = { | |
url: 'https://api.knack.com/v1/objects/object_5/records', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json', | |
'X-KNACK-APPLICATION-ID': bundle.authData.Knack-Application-Id , | |
'X-KNACK-REST-API-KEY': bundle.authData.Knack-REST-API-KEY | |
}, | |
params: { | |
'Knack-Application-Id ': bundle.authData.Knack-Application-Id , | |
'Knack-REST-API-KEY': bundle.authData.Knack-REST-API-KEY | |
}, | |
body: { | |
'field_14': bundle.inputData.field_14, | |
'field_15': bundle.inputData.field_15, | |
'field_13': bundle.inputData.field_13 | |
} | |
} | |
return z.request(options) | |
.then((response) => { | |
response.throwForStatus(); | |
const results = z.JSON.parse(response.content); | |
// You can do any parsing you need for results here before returning them | |
return results; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"inputData": { | |
"field_13": { | |
"first":"Jim", | |
"last": "Jones" | |
}, | |
"field_14": "jimjones@myself.com", | |
"field_15": "TestDem0." | |
}, | |
"authData": {}, | |
"environment": {}, | |
"subscribeData": {}, | |
"cleanedRequest": { | |
"url": "https://example.com/hook-request-origin", | |
"method": "POST", | |
"body": {}, | |
"headers": { | |
"Content-Type": "application/json" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"field_358": "johnfreelance@myself.com", | |
"field_226": "4000", | |
"field_314": "GBP", | |
"field_261": "services rendered in cyber security", | |
"field_271": "Google", | |
"field_272": "31/05/2020, | |
"field_273": "1123581324MO", | |
"field_277": "Jackie Jones", | |
"field_278": "jackie.jones@google.com", | |
"field_281": "+447956123456", | |
"field_282": "true", | |
"field_351": "true", | |
"field_352": "true", | |
"field_354": "true", | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment