No internet connection
  1. Home
  2. General

HTTP POST with an Array

By Mark Carpenter @mark.carpenter
    2021-05-07 20:33:02.458Z

    Any examples of HTTP POST action where the JSON passed to the API includes an array? Per JSON structure it should be [ {"key":"Value"}, ...] but perhaps I'm not sure how to indicate the array field name in the HTTP POST request. I've also tried providing the individual array elements as the Parameters describe, but to no avail. All non array parameters work fine. thanks! Mark

    • 8 replies
    1. A
      Benjamin @AutoBen
        2021-05-11 21:11:47.925Z

        Hi Mark, could show us what the output is when the %Exempt_regions% variable is written to a text file?

        1. MMark Carpenter @mark.carpenter
            2021-05-11 21:35:31.227Z

            Hi Ben,
            Two API calls in the attached "TA debug.tx" file. The first is an HTTP Get to be sure the customer does not already exist, so expecting a 404 return. Then the second is the HTTP Post with the return code 406. For each call there is an explanatory line followed by the return code, return values and return headers. For the HTTP Post, the %Exempt_regions% is below the return header. I have also uploaded to code snippet for context.

            TA debug.txt (3.85 KiB)

          • A
            In reply tomark.carpenter:
            Benjamin @AutoBen
              2021-05-11 22:32:22.949Z

              The variable in the HTTP Post action %Exempt_regions%, can you just write this to the text file? I'm curious to see what is being held in the variable as this is what should contain your array, am I correct?

              1. MMark Carpenter @mark.carpenter
                  2021-05-12 15:34:57.806Z

                  Here you go. I used line terminator "NONE"

                  TA debug.txt (768 B)

                  1. MMark Carpenter @mark.carpenter
                      2021-05-12 15:45:30.295Z

                      Note that the file has a %Exempt_regions% dump for each of two passes.

                  2. S
                    In reply tomark.carpenter:
                    Stephen Parker @stephenparker
                      2021-05-17 09:46:02.800Z

                      Is the API expecting Json? If so - it would be a Json post - not a regular POST (a regular POST sends as application/x-www-form-urlencoded).

                      1. MMark Carpenter @mark.carpenter
                          2021-05-17 12:51:29.921Z

                          Might be onto something. Changing to a JSON POST resulted in a bad parameter format error 400 instead of a not acceptable request 406 error. I have a session scheduled tomorrow morning and we'll see if we can put a nail in this once and for all. Also, I notice there is an HTTP Delete option and will put that to use as well.

                        • Progress
                        • M
                          Mark Carpenter @mark.carpenter
                            2021-05-18 15:07:50.094Z

                            This issue has been resolved. The JSON array was formatted properly but there was a syntax error passing the value across the api - no double quotes around the %variable% holding the JSON array did the trick.