Best way to ensure POST is successful

Hi team,

I’m running a XojoCloud server that does a little bit of work and then sends a POST to a restful API. The problem is that sometimes, for a period of time, the POST isn’t being received. The receiver is running on AWS and I’m not quite sure if it’s my end or theirs.

I’ve just implemented a database on the cloud to read the results of the post and was wondering what checks people do to ensure that the send is successful. As you can see below, I read the status and try 5 times before giving up. This code sits in a routine and the response is logged in a db on by cloud server. Any thoughts or improvements welcome!

CaptureSocketInstance.SetRequestContent(s, "application/x-www-form-urlencoded")

dim e as string
dim status as integer = 0
dim retry as integer

while status <> 201  '201 for local machine testing?
  retry = retry + 1
  if retry >5 then 
  end if
    e =  CaptureSocketInstance.SendSync("POST", "") '<> "{}"
    system.DebugLog "cant find capture server"
  end try
  status = CaptureSocketInstance.HTTPStatusCode
  system.DebugLog "Status = " + str(status)

Usually an API will return an http status code of 200 (OK) or 201 (CREATED) when it’s successful. The status will be 0 of the connection was not made.

1 Like

and even better if the api return/response something useful.