You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Logic Apps中从HTTP二进制输出生成PDF并保存到SharePoint的问题

Fixing Invalid PDF Generation from Atom XML HTTP Response in Power Automate

Let's break down why your current approaches aren't working and walk through the correct steps to get that PDF saved properly to SharePoint:

Why Your Previous Attempts Failed

  • When you pass body('HTTP') directly, you're sending the entire HTTP response object (including headers, status code, and nested body structure) instead of just the raw PDF data. SharePoint can't parse this into a valid file.
  • body('HTTP')?['content'] targets the wrong property—your actual content lives in body('HTTP')?['$content'], which is an Atom XML feed string, not direct binary PDF data.
  • Using base64ToBinary() without setting the correct content type makes SharePoint default to application/octet-stream, which doesn't tell the system it's a PDF, hence the opening error.

Step-by-Step Solution

  1. Extract the Atom XML Content
    First, grab the XML string from the HTTP response's $content property:

    body('HTTP')?['$content']
    
  2. Parse XML to Get Base64-encoded PDF Data
    Use Power Automate's xpath and xml functions to extract the base64 string representing your PDF from the Atom feed. The PDF data is typically stored inside the <content> tag of the feed's entry. Use this expression:

    first(xpath(xml(body('HTTP')?['$content']), '//content/text()'))
    
    • xml(...) converts the string into an XML object Power Automate can query.
    • xpath(..., '//content/text()') fetches all text inside <content> tags (this is your base64 PDF data).
    • first(...) picks the first result (since there should only be one PDF entry in the feed).
  3. Convert to Binary and Save to SharePoint
    When using SharePoint's Create file action:

    • Set the File Content field to:
      base64ToBinary(first(xpath(xml(body('HTTP')?['$content']), '//content/text()')))
      
    • Expand the Advanced options section and set Content Type to application/pdf.

This ensures you're passing the correct binary PDF data and telling SharePoint exactly what type of file it is, so it will save and open properly as a PDF.

内容的提问来源于stack exchange,提问作者Neo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 06:53:20