Skip to main content
Solved

REST API not creating new record


Forum|alt.badge.img

Hi All. I am using Post Man to create new records using PUT REST API in Acumatica. I have created new screen (grid view) and new table attach with Screen. I am trying to add new record but its not creating record but updating the existing one I have tried with if-none-match header but still the problem exist. The table have PK and Unique key. Any idea what’s going on? Thanks

 

Best answer by harutyungevorgyan

Hello @tahayabali ,


In your package there is no DLL, however, I found out that on your screen the PrimaryVIew is still written as “MasterView”. You should change it to “RSProduct” and probably that will solve your problem,

if not please send your source code as well, there is only an aspx of your screen and the project file in your customization package.

View original
Did this topic help you find an answer to your question?

28 replies

Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

Based on the screenshot, the primary key on your table is only on the CompanyID field and not the combination of CompanyID and, presumably, packing_id.  You’ll need to fix that in SQL or with DDL statements if you don’t have direct access to the SQL server.

That also means that your DAC is likely not using IsKey correctly. Can you share your DAC with us?


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

 


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

how can i create the combination? Packing Id is unique key in the table. So when ever we have new packing id it will create new record in Table.


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

What fields make up your primary key?  CompanyID and Packing_ID?  Is your Date field part of the primary key?

Also, you should avoid naming fields using reserved words, like “Date”.  You will also likely experience issues with fields that have underscores in their field names.

I’d recommend restarting the customization and renaming your fields to avoid problems as you get further into your project.


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

Company Id is my primary key and unqiue key is packing_id. Date field is not the part of any primary or unique. So you recommend me to remove underscores from fields name in screen or in the table?


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

Your primary key needs to be changed to CompanyID and packing_id. Then remove the unique key because that will cause problems if you create another tenant in that same database.

And, yes, I strongly recommend that you remove the underscores from the database field names.  Other programmers have found issues since the framework will use the underscore character when constructing queries and joins with other DACs.


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

Still the same problem its updating the existing one and not creating new one. Look at the table now and API. The screen shot is after when i changed it to 25698 before it was 4447
 

 


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

Share your new DAC - I suspect your issue will now be in there.

Side note, not important now, but the convention is to have CompanyID as your first column.


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

THis is new DAC.. 
 

 


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024


@Django 
namespace RSL_Product
{
  [Serializable]
  [PXCacheName("AGDC_RSLProduct")]
  public class AGDC_RSLProduct : IBqlTable
  {
    #region PackingID
    [PXDBInt(IsKey = true)]
    [PXUIField(DisplayName = "Packing ID")]
    public virtual int? PackingID { get; set; }
    public abstract class packingID : PX.Data.BQL.BqlInt.Field<packingID> { }
    #endregion

    #region PackingDescription
    [PXDBString(255, InputMask = "")]
    [PXUIField(DisplayName = "Packing Description")]
    public virtual string PackingDescription { get; set; }
    public abstract class packingDescription : PX.Data.BQL.BqlString.Field<packingDescription> { }
    #endregion

    #region Date
    [PXDBDate()]
    [PXUIField(DisplayName = "Date")]
    public virtual DateTime? Date { get; set; }
    public abstract class date : PX.Data.BQL.BqlDateTime.Field<date> { }
    #endregion

    #region Swrc
    [PXDBString(255, InputMask = "")]
    [PXUIField(DisplayName = "Swrc")]
    public virtual string Swrc { get; set; }
    public abstract class swrc : PX.Data.BQL.BqlString.Field<swrc> { }
    #endregion

    #region CaseCode
    [PXDBInt()]
    [PXUIField(DisplayName = "Case Code")]
    public virtual int? CaseCode { get; set; }
    public abstract class caseCode : PX.Data.BQL.BqlInt.Field<caseCode> { }
    #endregion

    #region CaseUpc
    [PXDBString(255, InputMask = "")]
    [PXUIField(DisplayName = "Case Upc")]
    public virtual string CaseUpc { get; set; }
    public abstract class caseUpc : PX.Data.BQL.BqlString.Field<caseUpc> { }
    #endregion
  }
}


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

That’s looking correct. Sometimes I need to do an application restart to get things actually working.

Something else to check - the graph that your web endpoint is connected to - does it work with adding multiple records?


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

You mean endpoints? Check screen shot below

@Django 

 


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

Your endpoint is connected to screen MA.20.88.61. Are you able to use that screen to enter multiple records into that table?


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

Nope it’s saving the records from screen too


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

Sorry - just to be clear, is that screen functioning properly?  Can you add / edit more than one record in that screen? 

The reason I ask is that the Endpoint is going to use that Graph for it’s business logic and if the screen isn’t working properly, then that will impact your Endpoint.


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

@Django It’s not saving from screen either
 

 


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

First thing to check is run a Restart Application (screen SM203510) and see that clears things up.

If it isn’t still working then it might be easier to re-create the screen, make sure that’s working, and then delete and re-create your endpoint. You need the screen to be working since your endpoint connects to the screen.


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

Do i need to create save or create action on screen ? I have created a simple screen with grid view only nothing else no entry forms or anything. Does this creating problem? 


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

Based on your screenshot I see the + button and the 💾 button so those will do everything the form needs to do to tell the graph to persist the data to the database.

You don’t need to add anything else.

But if that screen isn’t working, then the endpoint won’t work either.


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 6, 2024

@Django Yes there is button but when i am saving the data and click on it its not working when i reload the page it shows popup


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 6, 2024

If you share with us the popup, we might be able to see what’s wrong with the screen.

Alternatively, it might be easier just to delete and re-create the screen since it’s a fairly basic form.


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 7, 2024

@Django  the second record with packing id 5587 is not saving even i clicked on it and when i reload it shows me this

 


Forum|alt.badge.img+5
  • Captain II
  • 503 replies
  • May 7, 2024

It’s hard to tell if the issue is in the screen setup or in the graph. Can you package up your customization project and post it?


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 8, 2024

@Django here is my package. Please have a look and please guide me what I am missing. I have spent alot of time on it


Forum|alt.badge.img
  • Author
  • Varsity I
  • 114 replies
  • May 10, 2024

@Django did you get the time to check?

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings