API/API2 Automatic Reference Number not working

I tried to create a transaction via API and API2, it seems automatic reference is not working. The record is created, but the Reference Number is empty.

 // Create a new array for JSON objects
     $json = array(
         "Date" => "2024-02-28",

         "Reference" => null,
         "AutomaticReference" => true,
          ......
      )

But you explicitly set the reference to Null.

Could you please try again but this time just omit the entire ā€˜Referenceā€™ field from your request

I want an automatic reference number, what should I enter in the Reference Property? Iā€™ve tried Null, Nothing, Empty string and Delete Reference Property Line also no luck.

Displaying Property without Value in Json gives us an error.

image

PHP Script runs normally, but the result is the same, I donā€™t get the Reference Number

image

You still kept the ā€œRefernceā€ field name. Ommit that entire line and see what happens.

Same result

It seems Automatic Reference only works in GUI mode

Getting ideas and answers from this thread, Auto Reference does not work on API/API2.

Solved.

1 Like

I have tested this and you are right, the API doesnā€™t support auto references. I must have confused this with Batch Create which fully supports auto references.

I donā€™t know if thereā€™s any technical reasons for this though so Iā€™m going to keep this post open for @lubos to have the final say on this.

2 Likes

From the beginning of this topic I was trying to figure out why it would work and had hoped to see that somehow it could. My doubt was based on the fact that autoref needs a starting ref and continue with a +1 after that. This would require some query of the database to find the starting ref and then some logic to increment it and this would be ā€œloopedā€. For Manager app to do this is no problem but I would not know how to get the API doing it except if it does the query and increment by its own coding.

2 Likes