Add file API -> How should the request body look like?

Hello Everybody, 

I want to upload a file to HighQ with Power Automate.

I had no problem to solve this with Postman, but I have no clue how the body XML of the request should look like.

Currently I get the response, that my xml is not valid.

<file>here is the file content</file>

<filename>hieristhefilename.png</filename>

What <attributes> do I need to put on start and end of the body?

I studied all documentation (old and new stuff), but the information about the request body of all the endpoints are very poor. 

Every help is much appreciated. Thank you,

Philipp

Parents
  • Here’s a general approach for structuring an XML request body for a file upload, based on common practices. This might need adjustments depending on the HighQ API's exact requirements.

    Example XML Body Format for File Upload:

    xml
    Copy code
    <UploadFileRequest> <file> <![CDATA[BASE64_ENCODED_FILE_CONTENT]]> </file> <filename>hieristhefilename.png</filename> <attributes> <attribute1>value1</attribute1> <attribute2>value2</attribute2> <!-- Add more attributes as needed --> </attributes> </UploadFileRequest>

    Explanation:

    1. <UploadFileRequest>: This is the root element. The actual root element will depend on HighQ’s documentation, but typically, APIs define a request structure with an identifying root element.

    2. <file>: The file content is often included here, potentially Base64-encoded if the API requires it. Check whether HighQ requires you to Base64 encode the file content.

    3. <filename>: The file’s name. You seem to already be doing this correctly.

    4. <attributes>: This can be used to add additional metadata or parameters if needed, like file type, description, etc. If the API documentation specifies particular attributes, you should add them here.

    5. <![CDATA[ ... ]]>: In case the file content includes characters that might be misinterpreted as XML (like &, <, >), it’s good to wrap it in <![CDATA[ ... ]]> to ensure it’s treated as plain text.


    Things to Check:

    1. Encoding the File: Ensure the file is properly Base64-encoded if that’s what the API requires.

    2. HighQ Documentation: You might be missing some specific attribute or structural element required by HighQ. Some APIs require multipart/form-data or specific content types.

    3. Content-Type Header: When you are working with Power Automate, make sure to set the correct content type in the headers, often application/xml or multipart/form-data, depending on the API's specification.

    I am a developer and Academic writer at Nerdpapers. If you have more details from the documentation or the exact error response, feel free to share them, and I can help refine the solution further!

Reply
  • Here’s a general approach for structuring an XML request body for a file upload, based on common practices. This might need adjustments depending on the HighQ API's exact requirements.

    Example XML Body Format for File Upload:

    xml
    Copy code
    <UploadFileRequest> <file> <![CDATA[BASE64_ENCODED_FILE_CONTENT]]> </file> <filename>hieristhefilename.png</filename> <attributes> <attribute1>value1</attribute1> <attribute2>value2</attribute2> <!-- Add more attributes as needed --> </attributes> </UploadFileRequest>

    Explanation:

    1. <UploadFileRequest>: This is the root element. The actual root element will depend on HighQ’s documentation, but typically, APIs define a request structure with an identifying root element.

    2. <file>: The file content is often included here, potentially Base64-encoded if the API requires it. Check whether HighQ requires you to Base64 encode the file content.

    3. <filename>: The file’s name. You seem to already be doing this correctly.

    4. <attributes>: This can be used to add additional metadata or parameters if needed, like file type, description, etc. If the API documentation specifies particular attributes, you should add them here.

    5. <![CDATA[ ... ]]>: In case the file content includes characters that might be misinterpreted as XML (like &, <, >), it’s good to wrap it in <![CDATA[ ... ]]> to ensure it’s treated as plain text.


    Things to Check:

    1. Encoding the File: Ensure the file is properly Base64-encoded if that’s what the API requires.

    2. HighQ Documentation: You might be missing some specific attribute or structural element required by HighQ. Some APIs require multipart/form-data or specific content types.

    3. Content-Type Header: When you are working with Power Automate, make sure to set the correct content type in the headers, often application/xml or multipart/form-data, depending on the API's specification.

    I am a developer and Academic writer at Nerdpapers. If you have more details from the documentation or the exact error response, feel free to share them, and I can help refine the solution further!

Children
No Data