Skip to main content
Solved

How to resolve the following API error

  • January 19, 2024
  • 2 replies
  • 422 views

Forum|alt.badge.img

'{"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?

Best answer by Vignesh Ponnusamy

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,

2 replies

Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

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,


Troy Vars
Semi-Pro I
Forum|alt.badge.img+2
  • Semi-Pro I
  • January 23, 2024

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;