ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Working with API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Working with API

    I am posting data to a server API. Occasionally I get a response that does not sense, like an error for something that worked last time and nothing has changed. Should I do a retry when something like this happens, on the assumption that some transient glitch caused the problem? What kind of exceptions should I expect to handle?

    I am a newbie at this, and would appreciate any advice on how applications dealing with a web service should be designed.

  • #2
    That question would have to be posed to the devs responsible for the API you're calling.

    Comment


    • #3
      Why should questions like "Should I do a retry when something like this happens, on the assumption that some transient glitch caused the problem?" and "What kind of exceptions should I expect to handle?" be directed to the developers of the API?

      Comment


      • #4
        Unless the error specifies that the error is of a temporary nature then re-try is probably pointless.

        I suspect that the point jtaylor was trying to make is that such errors are rarely the responsibility of the using programmer. The APi provider should be sending specific error messages. Your job is to process them appropriately. If the data is scrambled then that is almost certainly the fault of the sender (i.e. the API provider) - I would expect network issues to usually result in a timeout or similar error.

        How are you doing the post? HTTPAPI or ?

        Comment


        • #5
          I am using HTTPAPI.

          How would you explain a 502 Bad Gateway response? I am posting several transactions and rarely get this response.

          Comment


          • #6
            502 Bad Gateway is a communication problem between the server you are connecting to and other computer that it connects to. There's nothing you can do to solve this in your code -- whomever is running the server needs to solve this problem.

            Comment


            • #7
              I agree. But, since I rarely get this response, would retrying the request be a reasonable action?

              Comment


              • #8
                Originally posted by LBurkett99 View Post
                I agree. But, since I rarely get this response, would retrying the request be a reasonable action?
                Yes. In general, when writing applications that need to do communications, things will go wrong sometimes -- I almost always code it so that it will retry failures a few times.

                Comment


                • #9
                  Thank you.

                  Comment

                  Working...
                  X