halite icon indicating copy to clipboard operation
halite copied to clipboard

JSON post issue

Open marcstein opened this issue 2 years ago • 1 comments

I have a cURL command that seems to work fine and also works from Postman, but I can seem to format it into Halite in such a way that it works.

The cURL is curl --location --request POST 'https://api-qa.employers.com/DigitalAgencyServices/quote'
--header 'appKey: xxxxxx'
--header 'appToken: xxxxxxx'
--header 'Content-Type: application/json'
--data-raw '{"id": "baca57f1-8bcc-4e21-b26b-27f0f3567567", "effectiveDate": "2022-04-19", "expirationDate": "2022-05-19", "yearsInBusiness": 5, "agency": {"agencyCode": "0001878"}, "agent": {"customerNumber": "0001878-CR00034268"}, "namedInsureds": [{"name": "Test+Restaurant", "fein": "333333334", "locations": [{"primary": true, "numberOfEmployees": 3, "address": {"state": "MA", "zipCode": "01864"}, "rateClasses": [{"classCode": "907908", "classCodeDescription": "", "payrollAmount": 100000}]}]}], "questions": [{"questionCode": "EMPCO-1000", "value": "false"}, {"questionCode": "EMPCO-1100", "value": "false"}, {"questionCode": "EMPCO-1001", "value": "false"}, {"questionCode": "EMPCO-1101", "value": "false"}, {"questionCode": "EMPCO-1002", "value": "false"}, {"questionCode": "EMPCO-1007", "value": "false"}, {"questionCode": "EMPCO-1004", "value": "false"}, {"questionCode": "EMPCO-1104", "value": "false"}, {"questionCode": "EMPCO-1105", "value": "false"}, {"questionCode": "EMPCO-1005", "value": "false"}, {"questionCode": "EMPCO-1006", "value": "false"}, {"questionCode": "EMPCO-3001", "value": "false"}, {"questionCode": "EMPCO-3011", "value": "false"}, {"questionCode": "EMPCO-163", "value": "false"}, {"questionCode": "EMPCO-164", "value": "false"}, {"questionCode": "EMPCO-3012", "value": "false"}, {"questionCode": "EMPCO-3003", "value": "false"}, {"questionCode": "EMPCO-3009", "value": "false"}, {"questionCode": "EMPCO-3109", "value": "false"}, {"questionCode": "EMPCO-3209", "value": "false"}, {"questionCode": "EMPCO-3010", "value": "false"}, {"questionCode": "EMPCO-3013", "value": "false"}, {"questionCode": "EMPCO-512", "value": "false"}, {"questionCode": "EMPCO-3014", "value": "false"}, {"questionCode": "EMPCO-3015", "value": "false"}, {"questionCode": "EMPCO-3007", "value": "false"}, {"questionCode": "EMPCO-3008", "value": "false"}, {"questionCode": "EMPCO-3016", "value": "false"}, {"questionCode": "EMPCO-3017", "value": "false"}, {"questionCode": "EMPCO-3018", "value": "false"}, {"questionCode": "EMPCO-3118", "value": "false"}, {"questionCode": "EMPCO-3218", "value": "false"}, {"questionCode": "EMPCO-3019", "value": "false"}]}'

I've tried variations on

# Set content-type manually

response = Halite.post("https://api-qa.employers.com/DigitalAgencyServices/quote", headers: {"content-type" => "application/json", "appKey=" => "xxxx", "appToken" => "xxxxx"}, raw: quote.to_json )

where quote is the data in any number of different formats.

What would be the correct appoach?

Many thanks in advance!

marcstein avatar Apr 19 '22 22:04 marcstein

https://github.com/icyleaf/halite#json-data

icyleaf avatar Apr 21 '22 02:04 icyleaf