Solved

How to resolve the following API error

  • 19 January 2024
  • 2 replies
  • 65 views

Userlevel 4
Badge

'{"error":{"code":400,"details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","metadata":{"action_name":"CreateAttachment","cause":"Invalid input for attribute Content to operation CreateAttachment.rsb, only InputStream is allowed.","connection_type":"Acumatica"}}],"message":"Unable to execute the specified action.","status":"FAILED_PRECONDITION"}}'

 

We have been trying to pass CreateAttachment action, but it displays the following error. What kind of InputStream shall we provide? Any Ideas?

icon

Best answer by Vignesh Ponnusamy 19 January 2024, 15:54

View original

2 replies

Userlevel 7
Badge +4

Hi @Harry,

Following help document details the steps to add an attachment to a document, 

https://help.acumatica.com/(W(3))/Help?ScreenId=ShowWiki&pageid=591def3d-5fe5-42c1-bb35-cfe5b4c77f6f

Can you please share more context like screen(to which you are trying to add an attachment), about the CreateAttachment action you are referring? Share the endpoint URL to which you are making the request. Screenshots will help the community member understand the issue precisely. Thanks,

Userlevel 4
Badge +2

This really depends on what Tech stack you are utilizing below is one example from a raw C# HTTP standpoint.

The one gotcha I find with files is to make sure that File Upload preferences include the file type you are trying to upload. 

In C# Typically I will Open a FileStream via something Like 

          fileStream = IO.File.OpenRead(Path+fileName);

then set this to the content of my request

         request = new HttpRequestMessage(HttpMethod.Put,url)

          request.Content = new StreamContent(fileStream);

then send the request and await the result message

          response = requestMessage.SendAsync(request).Result;

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved