Can I delete a file in Acumatica via the API?












0















I'm creating a file in Acumatica by calling an action from the API, so that I can retrieve the file in my application.



Is it possible to delete the file via API after I'm done with it? I'd rather not have it cluttering up my Acumatica database.



Failing this, is there a recommended cleanup approach for these files?










share|improve this question



























    0















    I'm creating a file in Acumatica by calling an action from the API, so that I can retrieve the file in my application.



    Is it possible to delete the file via API after I'm done with it? I'd rather not have it cluttering up my Acumatica database.



    Failing this, is there a recommended cleanup approach for these files?










    share|improve this question

























      0












      0








      0








      I'm creating a file in Acumatica by calling an action from the API, so that I can retrieve the file in my application.



      Is it possible to delete the file via API after I'm done with it? I'd rather not have it cluttering up my Acumatica database.



      Failing this, is there a recommended cleanup approach for these files?










      share|improve this question














      I'm creating a file in Acumatica by calling an action from the API, so that I can retrieve the file in my application.



      Is it possible to delete the file via API after I'm done with it? I'd rather not have it cluttering up my Acumatica database.



      Failing this, is there a recommended cleanup approach for these files?







      acumatica






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 18:17









      June BJune B

      9110




      9110
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Found examples of how to delete a file from within Acumatica, as well as how to save a new version of an existing file! The below implementation saves a new version but has the deletion method commented out. Because I built this into my report generation process, I'm not later deleting the report via API, but it would be easy to translate a deletion into an action callable by the API.



          private IEnumerable ExportReport(PXAdapter adapter, string reportID, Dictionary<String, String> parameters)
          {
          //Press save if the SO is not completed
          if (Base.Document.Current.Completed == false)
          {
          Base.Save.Press();
          }

          PX.SM.FileInfo file = null;
          using (Report report = PXReportTools.LoadReport(reportID, null))
          {
          if (report == null)
          {
          throw new Exception("Unable to access Acumatica report writer for specified report : " + reportID);
          }

          PXReportTools.InitReportParameters(report, parameters, PXSettingProvider.Instance.Default);
          ReportNode reportNode = ReportProcessor.ProcessReport(report);
          IRenderFilter renderFilter = ReportProcessor.GetRenderer(ReportProcessor.FilterPdf);

          //Generate the PDF
          byte data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterPdf).First();
          file = new PX.SM.FileInfo(reportNode.ExportFileName + ".pdf", null, data);

          //Save the PDF to the SO
          UploadFileMaintenance graph = new UploadFileMaintenance();

          //Check to see if a file with this name already exists
          Guid files = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current);
          foreach (Guid fileID in files)
          {
          FileInfo existingFile = graph.GetFileWithNoData(fileID);
          if (existingFile.Name == reportNode.ExportFileName + ".pdf")
          {
          //If we later decide we want to delete previous versions instead of saving them, this can be changed to
          //UploadFileMaintenance.DeleteFile(existingFile.UID);
          //But in the meantime, for history purposes, set the UID of the new file to that of the existing file so we can save it as a new version.
          file.UID = existingFile.UID;
          }
          }

          //Save the file with the setting to create a new version if one already exists based on the UID
          graph.SaveFile(file, FileExistsAction.CreateVersion);
          //Save the note attribute so we can find it again.
          PXNoteAttribute.AttachFile(Base.Document.Cache, Base.Document.Current, file);
          }

          //Return the info on the file
          return adapter.Get();
          }





          share|improve this answer































            0














            The response from Acumatica:
            S-b (Screen-base) API allows clean way of downloading report generated as file. C-b (Contract-base) simply does not have this feature added. I suggest you provided feedback here: feedback.acumatica.com (EDIT: Done! https://feedback.acumatica.com/ideas/ACU-I-1852)



            I think couple of workaround are:
            1) use s-b using login from c-b to generate report and get as file (see example below), or
            2) create another method to delete the file once required report file is downloaded. For that, you will need to pass back FileID or something to identify for deletion.



            example of #1



                    using (DefaultSoapClient sc = new DefaultSoapClient("DefaultSoap1"))
            {
            string sharedCookie;
            using (new OperationContextScope(sc.InnerChannel))
            {
            sc.Login("admin", "123", "Company", null, null);
            var responseMessageProperty = (HttpResponseMessageProperty)
            OperationContext.Current.IncomingMessageProperties[HttpResponseMessageProperty.Name];
            sharedCookie = responseMessageProperty.Headers.Get("Set-Cookie");
            }

            try
            {
            Screen scr = new Screen(); // add reference to report e.g. http://localhost/Demo2018R2/Soap/SO641010.asmx
            scr.CookieContainer = new System.Net.CookieContainer();
            scr.CookieContainer.SetCookies(new Uri(scr.Url), sharedCookie);

            var schema = scr.GetSchema();
            var commands = new Command
            {
            new Value { LinkedCommand = schema.Parameters.OrderType, Value = "SO" },
            new Value { LinkedCommand = schema.Parameters.OrderNumber, Value = "SO004425" },
            schema.ReportResults.PdfContent
            };

            var data = scr.Submit(commands);
            if(data != null && data.Length > 0)
            {
            System.IO.File.WriteAllBytes(@"c:TempSalesOrder.pdf",
            Convert.FromBase64String(data[0].ReportResults.PdfContent.Value));
            }
            }
            finally
            {
            sc.Logout();
            }
            }


            Hope this helps. Also, it would be great if you update the stackover post based on these suggestions.



            Thanks



            Nayan Mansinha
            Lead - Developer Support | Acumatica






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380495%2fcan-i-delete-a-file-in-acumatica-via-the-api%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              Found examples of how to delete a file from within Acumatica, as well as how to save a new version of an existing file! The below implementation saves a new version but has the deletion method commented out. Because I built this into my report generation process, I'm not later deleting the report via API, but it would be easy to translate a deletion into an action callable by the API.



              private IEnumerable ExportReport(PXAdapter adapter, string reportID, Dictionary<String, String> parameters)
              {
              //Press save if the SO is not completed
              if (Base.Document.Current.Completed == false)
              {
              Base.Save.Press();
              }

              PX.SM.FileInfo file = null;
              using (Report report = PXReportTools.LoadReport(reportID, null))
              {
              if (report == null)
              {
              throw new Exception("Unable to access Acumatica report writer for specified report : " + reportID);
              }

              PXReportTools.InitReportParameters(report, parameters, PXSettingProvider.Instance.Default);
              ReportNode reportNode = ReportProcessor.ProcessReport(report);
              IRenderFilter renderFilter = ReportProcessor.GetRenderer(ReportProcessor.FilterPdf);

              //Generate the PDF
              byte data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterPdf).First();
              file = new PX.SM.FileInfo(reportNode.ExportFileName + ".pdf", null, data);

              //Save the PDF to the SO
              UploadFileMaintenance graph = new UploadFileMaintenance();

              //Check to see if a file with this name already exists
              Guid files = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current);
              foreach (Guid fileID in files)
              {
              FileInfo existingFile = graph.GetFileWithNoData(fileID);
              if (existingFile.Name == reportNode.ExportFileName + ".pdf")
              {
              //If we later decide we want to delete previous versions instead of saving them, this can be changed to
              //UploadFileMaintenance.DeleteFile(existingFile.UID);
              //But in the meantime, for history purposes, set the UID of the new file to that of the existing file so we can save it as a new version.
              file.UID = existingFile.UID;
              }
              }

              //Save the file with the setting to create a new version if one already exists based on the UID
              graph.SaveFile(file, FileExistsAction.CreateVersion);
              //Save the note attribute so we can find it again.
              PXNoteAttribute.AttachFile(Base.Document.Cache, Base.Document.Current, file);
              }

              //Return the info on the file
              return adapter.Get();
              }





              share|improve this answer




























                1














                Found examples of how to delete a file from within Acumatica, as well as how to save a new version of an existing file! The below implementation saves a new version but has the deletion method commented out. Because I built this into my report generation process, I'm not later deleting the report via API, but it would be easy to translate a deletion into an action callable by the API.



                private IEnumerable ExportReport(PXAdapter adapter, string reportID, Dictionary<String, String> parameters)
                {
                //Press save if the SO is not completed
                if (Base.Document.Current.Completed == false)
                {
                Base.Save.Press();
                }

                PX.SM.FileInfo file = null;
                using (Report report = PXReportTools.LoadReport(reportID, null))
                {
                if (report == null)
                {
                throw new Exception("Unable to access Acumatica report writer for specified report : " + reportID);
                }

                PXReportTools.InitReportParameters(report, parameters, PXSettingProvider.Instance.Default);
                ReportNode reportNode = ReportProcessor.ProcessReport(report);
                IRenderFilter renderFilter = ReportProcessor.GetRenderer(ReportProcessor.FilterPdf);

                //Generate the PDF
                byte data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterPdf).First();
                file = new PX.SM.FileInfo(reportNode.ExportFileName + ".pdf", null, data);

                //Save the PDF to the SO
                UploadFileMaintenance graph = new UploadFileMaintenance();

                //Check to see if a file with this name already exists
                Guid files = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current);
                foreach (Guid fileID in files)
                {
                FileInfo existingFile = graph.GetFileWithNoData(fileID);
                if (existingFile.Name == reportNode.ExportFileName + ".pdf")
                {
                //If we later decide we want to delete previous versions instead of saving them, this can be changed to
                //UploadFileMaintenance.DeleteFile(existingFile.UID);
                //But in the meantime, for history purposes, set the UID of the new file to that of the existing file so we can save it as a new version.
                file.UID = existingFile.UID;
                }
                }

                //Save the file with the setting to create a new version if one already exists based on the UID
                graph.SaveFile(file, FileExistsAction.CreateVersion);
                //Save the note attribute so we can find it again.
                PXNoteAttribute.AttachFile(Base.Document.Cache, Base.Document.Current, file);
                }

                //Return the info on the file
                return adapter.Get();
                }





                share|improve this answer


























                  1












                  1








                  1







                  Found examples of how to delete a file from within Acumatica, as well as how to save a new version of an existing file! The below implementation saves a new version but has the deletion method commented out. Because I built this into my report generation process, I'm not later deleting the report via API, but it would be easy to translate a deletion into an action callable by the API.



                  private IEnumerable ExportReport(PXAdapter adapter, string reportID, Dictionary<String, String> parameters)
                  {
                  //Press save if the SO is not completed
                  if (Base.Document.Current.Completed == false)
                  {
                  Base.Save.Press();
                  }

                  PX.SM.FileInfo file = null;
                  using (Report report = PXReportTools.LoadReport(reportID, null))
                  {
                  if (report == null)
                  {
                  throw new Exception("Unable to access Acumatica report writer for specified report : " + reportID);
                  }

                  PXReportTools.InitReportParameters(report, parameters, PXSettingProvider.Instance.Default);
                  ReportNode reportNode = ReportProcessor.ProcessReport(report);
                  IRenderFilter renderFilter = ReportProcessor.GetRenderer(ReportProcessor.FilterPdf);

                  //Generate the PDF
                  byte data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterPdf).First();
                  file = new PX.SM.FileInfo(reportNode.ExportFileName + ".pdf", null, data);

                  //Save the PDF to the SO
                  UploadFileMaintenance graph = new UploadFileMaintenance();

                  //Check to see if a file with this name already exists
                  Guid files = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current);
                  foreach (Guid fileID in files)
                  {
                  FileInfo existingFile = graph.GetFileWithNoData(fileID);
                  if (existingFile.Name == reportNode.ExportFileName + ".pdf")
                  {
                  //If we later decide we want to delete previous versions instead of saving them, this can be changed to
                  //UploadFileMaintenance.DeleteFile(existingFile.UID);
                  //But in the meantime, for history purposes, set the UID of the new file to that of the existing file so we can save it as a new version.
                  file.UID = existingFile.UID;
                  }
                  }

                  //Save the file with the setting to create a new version if one already exists based on the UID
                  graph.SaveFile(file, FileExistsAction.CreateVersion);
                  //Save the note attribute so we can find it again.
                  PXNoteAttribute.AttachFile(Base.Document.Cache, Base.Document.Current, file);
                  }

                  //Return the info on the file
                  return adapter.Get();
                  }





                  share|improve this answer













                  Found examples of how to delete a file from within Acumatica, as well as how to save a new version of an existing file! The below implementation saves a new version but has the deletion method commented out. Because I built this into my report generation process, I'm not later deleting the report via API, but it would be easy to translate a deletion into an action callable by the API.



                  private IEnumerable ExportReport(PXAdapter adapter, string reportID, Dictionary<String, String> parameters)
                  {
                  //Press save if the SO is not completed
                  if (Base.Document.Current.Completed == false)
                  {
                  Base.Save.Press();
                  }

                  PX.SM.FileInfo file = null;
                  using (Report report = PXReportTools.LoadReport(reportID, null))
                  {
                  if (report == null)
                  {
                  throw new Exception("Unable to access Acumatica report writer for specified report : " + reportID);
                  }

                  PXReportTools.InitReportParameters(report, parameters, PXSettingProvider.Instance.Default);
                  ReportNode reportNode = ReportProcessor.ProcessReport(report);
                  IRenderFilter renderFilter = ReportProcessor.GetRenderer(ReportProcessor.FilterPdf);

                  //Generate the PDF
                  byte data = PX.Reports.Mail.Message.GenerateReport(reportNode, ReportProcessor.FilterPdf).First();
                  file = new PX.SM.FileInfo(reportNode.ExportFileName + ".pdf", null, data);

                  //Save the PDF to the SO
                  UploadFileMaintenance graph = new UploadFileMaintenance();

                  //Check to see if a file with this name already exists
                  Guid files = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current);
                  foreach (Guid fileID in files)
                  {
                  FileInfo existingFile = graph.GetFileWithNoData(fileID);
                  if (existingFile.Name == reportNode.ExportFileName + ".pdf")
                  {
                  //If we later decide we want to delete previous versions instead of saving them, this can be changed to
                  //UploadFileMaintenance.DeleteFile(existingFile.UID);
                  //But in the meantime, for history purposes, set the UID of the new file to that of the existing file so we can save it as a new version.
                  file.UID = existingFile.UID;
                  }
                  }

                  //Save the file with the setting to create a new version if one already exists based on the UID
                  graph.SaveFile(file, FileExistsAction.CreateVersion);
                  //Save the note attribute so we can find it again.
                  PXNoteAttribute.AttachFile(Base.Document.Cache, Base.Document.Current, file);
                  }

                  //Return the info on the file
                  return adapter.Get();
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 14 '18 at 19:00









                  June BJune B

                  9110




                  9110

























                      0














                      The response from Acumatica:
                      S-b (Screen-base) API allows clean way of downloading report generated as file. C-b (Contract-base) simply does not have this feature added. I suggest you provided feedback here: feedback.acumatica.com (EDIT: Done! https://feedback.acumatica.com/ideas/ACU-I-1852)



                      I think couple of workaround are:
                      1) use s-b using login from c-b to generate report and get as file (see example below), or
                      2) create another method to delete the file once required report file is downloaded. For that, you will need to pass back FileID or something to identify for deletion.



                      example of #1



                              using (DefaultSoapClient sc = new DefaultSoapClient("DefaultSoap1"))
                      {
                      string sharedCookie;
                      using (new OperationContextScope(sc.InnerChannel))
                      {
                      sc.Login("admin", "123", "Company", null, null);
                      var responseMessageProperty = (HttpResponseMessageProperty)
                      OperationContext.Current.IncomingMessageProperties[HttpResponseMessageProperty.Name];
                      sharedCookie = responseMessageProperty.Headers.Get("Set-Cookie");
                      }

                      try
                      {
                      Screen scr = new Screen(); // add reference to report e.g. http://localhost/Demo2018R2/Soap/SO641010.asmx
                      scr.CookieContainer = new System.Net.CookieContainer();
                      scr.CookieContainer.SetCookies(new Uri(scr.Url), sharedCookie);

                      var schema = scr.GetSchema();
                      var commands = new Command
                      {
                      new Value { LinkedCommand = schema.Parameters.OrderType, Value = "SO" },
                      new Value { LinkedCommand = schema.Parameters.OrderNumber, Value = "SO004425" },
                      schema.ReportResults.PdfContent
                      };

                      var data = scr.Submit(commands);
                      if(data != null && data.Length > 0)
                      {
                      System.IO.File.WriteAllBytes(@"c:TempSalesOrder.pdf",
                      Convert.FromBase64String(data[0].ReportResults.PdfContent.Value));
                      }
                      }
                      finally
                      {
                      sc.Logout();
                      }
                      }


                      Hope this helps. Also, it would be great if you update the stackover post based on these suggestions.



                      Thanks



                      Nayan Mansinha
                      Lead - Developer Support | Acumatica






                      share|improve this answer




























                        0














                        The response from Acumatica:
                        S-b (Screen-base) API allows clean way of downloading report generated as file. C-b (Contract-base) simply does not have this feature added. I suggest you provided feedback here: feedback.acumatica.com (EDIT: Done! https://feedback.acumatica.com/ideas/ACU-I-1852)



                        I think couple of workaround are:
                        1) use s-b using login from c-b to generate report and get as file (see example below), or
                        2) create another method to delete the file once required report file is downloaded. For that, you will need to pass back FileID or something to identify for deletion.



                        example of #1



                                using (DefaultSoapClient sc = new DefaultSoapClient("DefaultSoap1"))
                        {
                        string sharedCookie;
                        using (new OperationContextScope(sc.InnerChannel))
                        {
                        sc.Login("admin", "123", "Company", null, null);
                        var responseMessageProperty = (HttpResponseMessageProperty)
                        OperationContext.Current.IncomingMessageProperties[HttpResponseMessageProperty.Name];
                        sharedCookie = responseMessageProperty.Headers.Get("Set-Cookie");
                        }

                        try
                        {
                        Screen scr = new Screen(); // add reference to report e.g. http://localhost/Demo2018R2/Soap/SO641010.asmx
                        scr.CookieContainer = new System.Net.CookieContainer();
                        scr.CookieContainer.SetCookies(new Uri(scr.Url), sharedCookie);

                        var schema = scr.GetSchema();
                        var commands = new Command
                        {
                        new Value { LinkedCommand = schema.Parameters.OrderType, Value = "SO" },
                        new Value { LinkedCommand = schema.Parameters.OrderNumber, Value = "SO004425" },
                        schema.ReportResults.PdfContent
                        };

                        var data = scr.Submit(commands);
                        if(data != null && data.Length > 0)
                        {
                        System.IO.File.WriteAllBytes(@"c:TempSalesOrder.pdf",
                        Convert.FromBase64String(data[0].ReportResults.PdfContent.Value));
                        }
                        }
                        finally
                        {
                        sc.Logout();
                        }
                        }


                        Hope this helps. Also, it would be great if you update the stackover post based on these suggestions.



                        Thanks



                        Nayan Mansinha
                        Lead - Developer Support | Acumatica






                        share|improve this answer


























                          0












                          0








                          0







                          The response from Acumatica:
                          S-b (Screen-base) API allows clean way of downloading report generated as file. C-b (Contract-base) simply does not have this feature added. I suggest you provided feedback here: feedback.acumatica.com (EDIT: Done! https://feedback.acumatica.com/ideas/ACU-I-1852)



                          I think couple of workaround are:
                          1) use s-b using login from c-b to generate report and get as file (see example below), or
                          2) create another method to delete the file once required report file is downloaded. For that, you will need to pass back FileID or something to identify for deletion.



                          example of #1



                                  using (DefaultSoapClient sc = new DefaultSoapClient("DefaultSoap1"))
                          {
                          string sharedCookie;
                          using (new OperationContextScope(sc.InnerChannel))
                          {
                          sc.Login("admin", "123", "Company", null, null);
                          var responseMessageProperty = (HttpResponseMessageProperty)
                          OperationContext.Current.IncomingMessageProperties[HttpResponseMessageProperty.Name];
                          sharedCookie = responseMessageProperty.Headers.Get("Set-Cookie");
                          }

                          try
                          {
                          Screen scr = new Screen(); // add reference to report e.g. http://localhost/Demo2018R2/Soap/SO641010.asmx
                          scr.CookieContainer = new System.Net.CookieContainer();
                          scr.CookieContainer.SetCookies(new Uri(scr.Url), sharedCookie);

                          var schema = scr.GetSchema();
                          var commands = new Command
                          {
                          new Value { LinkedCommand = schema.Parameters.OrderType, Value = "SO" },
                          new Value { LinkedCommand = schema.Parameters.OrderNumber, Value = "SO004425" },
                          schema.ReportResults.PdfContent
                          };

                          var data = scr.Submit(commands);
                          if(data != null && data.Length > 0)
                          {
                          System.IO.File.WriteAllBytes(@"c:TempSalesOrder.pdf",
                          Convert.FromBase64String(data[0].ReportResults.PdfContent.Value));
                          }
                          }
                          finally
                          {
                          sc.Logout();
                          }
                          }


                          Hope this helps. Also, it would be great if you update the stackover post based on these suggestions.



                          Thanks



                          Nayan Mansinha
                          Lead - Developer Support | Acumatica






                          share|improve this answer













                          The response from Acumatica:
                          S-b (Screen-base) API allows clean way of downloading report generated as file. C-b (Contract-base) simply does not have this feature added. I suggest you provided feedback here: feedback.acumatica.com (EDIT: Done! https://feedback.acumatica.com/ideas/ACU-I-1852)



                          I think couple of workaround are:
                          1) use s-b using login from c-b to generate report and get as file (see example below), or
                          2) create another method to delete the file once required report file is downloaded. For that, you will need to pass back FileID or something to identify for deletion.



                          example of #1



                                  using (DefaultSoapClient sc = new DefaultSoapClient("DefaultSoap1"))
                          {
                          string sharedCookie;
                          using (new OperationContextScope(sc.InnerChannel))
                          {
                          sc.Login("admin", "123", "Company", null, null);
                          var responseMessageProperty = (HttpResponseMessageProperty)
                          OperationContext.Current.IncomingMessageProperties[HttpResponseMessageProperty.Name];
                          sharedCookie = responseMessageProperty.Headers.Get("Set-Cookie");
                          }

                          try
                          {
                          Screen scr = new Screen(); // add reference to report e.g. http://localhost/Demo2018R2/Soap/SO641010.asmx
                          scr.CookieContainer = new System.Net.CookieContainer();
                          scr.CookieContainer.SetCookies(new Uri(scr.Url), sharedCookie);

                          var schema = scr.GetSchema();
                          var commands = new Command
                          {
                          new Value { LinkedCommand = schema.Parameters.OrderType, Value = "SO" },
                          new Value { LinkedCommand = schema.Parameters.OrderNumber, Value = "SO004425" },
                          schema.ReportResults.PdfContent
                          };

                          var data = scr.Submit(commands);
                          if(data != null && data.Length > 0)
                          {
                          System.IO.File.WriteAllBytes(@"c:TempSalesOrder.pdf",
                          Convert.FromBase64String(data[0].ReportResults.PdfContent.Value));
                          }
                          }
                          finally
                          {
                          sc.Logout();
                          }
                          }


                          Hope this helps. Also, it would be great if you update the stackover post based on these suggestions.



                          Thanks



                          Nayan Mansinha
                          Lead - Developer Support | Acumatica







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 4 '18 at 22:16









                          June BJune B

                          9110




                          9110






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380495%2fcan-i-delete-a-file-in-acumatica-via-the-api%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                              How to change which sound is reproduced for terminal bell?

                              Can I use Tabulator js library in my java Spring + Thymeleaf project?