Duplicate submission error

I am using client_search (by account ref) to retrieve ClientID, followed by client_get. I seem to randomly get an error “Duplicate submission number”. I can’t forcefully recreate it but it happens about 60% of the time, then if I refresh it might happen again, refresh again and it works perfectly. Is there a certain amount of time that should pass between API calls? This particular call should only run once per month but during testing it fails when I run them within seconds of each other but I can’t afford for this to be failing on the production monthly runs. Is this a bug or something else needed?

Hi @Dean_Morgan

Are you 100% using a different submission number between calls?

@QFMathew not sure where I would set that? I don’t see it in the docs or the example json for any of the methods I am using…but the fact that it only happens sometimes and not other times makes me think it isn’t something I have set or not set?

Hi @Dean_Morgan

A unique submission number should be set for each API call as part of the Header:

It could be a number of things - for example, how are you generating the submission number? Is it possible that they would have been used before (e.g. if you have been testing code)?

ah I see- I was just using php time() for that. So theoretically that should at least increment by 1 between calls

Depends how quickly you’re making consecutive calls. If there’s less than one second between the client_search and the client_get then you’ll get a duplicate (as time() only has one second granularity).

What I do when I’m writing code to call the APIs is to generate an initial value derived from the current time once at the start of my program, then use that with an incrementing trailer for each request, so the first one might be 10478243-000, the second 10478243-001, etc. As long as you don’t run the program twice in the same second that should be guaranteed unique for each call.

thanks, I’ll give that a go!

You may want to look at using something like the uniqid() function. It’s still time based, but on microseconds.

There’s more information here: https://www.php.net/manual/en/function.uniqid.php

This topic was automatically closed after 7 days. New replies are no longer allowed.