oData POST question

  • oData POST question

    Posted by DSC Communities on March 14, 2018 at 7:20 am
    • Axel Gunnlaugsson

      Member

      March 14, 2018 at 7:20 AM

      Hi

      My first post here, so excuse the level of this question.

      I am using Postman to play with oData services. See how they work.
      Already cuccessfully created a SalesOrder using this one: https://<apiUrl>/OData/Company('<MyCompany&gt;’)/WebSalesOrder.
      Everything worked fine and my order #1050 got created.

      Now I want to add lines to this order and I am attemtting to use this service
      https://<apiUrl>/OData/Company('<MyCompany&gt;’)/WebSalesOrderLine?, but do not have enough info on doing it correctly. Input body seems ok, and I include my SalesOrder number as “Document_No” but (a) total fail if I try to add a list of lines, and when trying to add only one line I get a reply saying that my Document_no is missing.

      Please help šŸ™‚

      Axel

      ——————————
      Axel Gunnlaugsson
      Intraz
      ——————————

    • Franz Kalchmair

      Member

      March 18, 2018 at 4:33 PM

      adding a sales line via nav odata web service using c# would work with:

      using ConsoleApplication1.ServiceReference1;
      namespace ConsoleApplication1
      {
      class Program
      {
      static void Main(string[] args)
      {
      var uri = new Uri(“http://archer:7048/DynamicsNAV100/OData/Company(‘CRONUS’)”);
      NAV client = new NAV(uri);
      client.Credentials = CredentialCache.DefaultNetworkCredentials;
      var order = client.SalesOrder.FirstOrDefault();
      client.LoadProperty(order, “SalesOrderSalesLines”);
      var lastLineNo = order.SalesOrderSalesLines.Last().Line_No;
      var salesLine = SalesOrderSalesLines.CreateSalesOrderSalesLines(order.Document_Type, order.No, lastLineNo + 10000);
      client.AddToSalesOrderSalesLines(salesLine);
      client.SaveChanges();
      }
      }
      }

      maybe that helps.

      ——————————
      Franz Kalchmair
      Microsoft MVP
      Senior Consultant
      Vienna, Austria, Europe
      ——————————
      ——————————————-

    DSC Communities replied 8 years ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘oData POST question’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!