簡體   English   中英

Mule - Salesforce 連接器 - 檢索作業失敗結果批量 v2 - 不返回失敗數據

[英]Mule - Salesforce connector - Retrieve job failed results bulk v2 - not returning failed data

我在 Mule 中查詢 Salesforce Bulk api 失敗結果。 但它不獲取數據。 它只顯示記錄 ID 和錯誤消息。 但是,如果我檢查工作台,它會顯示 id、錯誤、數據列(a、b、c)如何獲取這些詳細信息。有沒有其他方法可以在 Mule 中獲取批量 api v2 失敗結果

在此處輸入圖像描述

在記錄之前進行簡單的轉換

%dw 2.0
output application/json
---
payload

調試日志:

在此處輸入圖像描述

在工作台上,我得到了實際數據。

在此處輸入圖像描述

請分享您的想法為什么我看不到這些數據

@RestResource(urlMapping='/bulkapi/failures') 
global without sharing class RestGetBulkAPIResults 
{
    @HttpGet
    global static void getFailedRecords()
    {
       RestRequest req = RestContext.request;
       RestResponse res = RestContext.response;
       res.addHeader('Content-Type', 'application/json');

        Http http = new Http();
        HttpRequest httpReq = new HttpRequest();
        HttpResponse httpRes = new HttpResponse();
        httpReq.setMethod('GET');
        httpReq.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
        string path = '/services/data/v48.0/jobs/ingest/7502i000001fJG9AAM/failedResults/';
        httpReq.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm()+ path);
        httpRes = http.send(httpReq);
        
        string op = httpRes.getBody();
        string[] rowList = op.split('\n');
        
        string[] headers = rowList[0].split(',');
        integer columnsCount = headers.size();
        integer dataRowsCount = rowList.size();
        
        string fullFormattedData = '[';
        for(integer rowIndex =1; rowIndex < dataRowsCount; rowIndex++)
        {
      string[] rowData = rowList[rowIndex].split(','); 
            
            string rowJsonData ='{';
            for(integer columnIndex=0; columnIndex < columnsCount; columnIndex++)
            {
        rowJsonData += headers[columnIndex] + ':' + rowData[columnIndex] + ',';
            }
            rowJsonData = rowJsonData.removeEnd(',');
            rowJsonData += '}';
            fullFormattedData += rowJsonData;
        }
        fullFormattedData += ']';
        
        system.debug('resp' + httpRes.getBody());
        res.responseBody = Blob.valueOf(fullFormattedData);
        res.statusCode = 200;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM