我尝试使用 Azure Data Factory V2 中的 REST API 连接器从 ServiceNow 表中提取数据。在提取数据时,我有时会收到以下错误,有时则没有收到任何错误,并且管道已成功运行。
{
"errorCode": "2200",
"message": "Failure happened on 'Source' side. ErrorCode=UserErrorInvalidJsonDataFormat,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Error occurred when deserializing source JSON data. Please check if the data is in valid JSON object format.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=Newtonsoft.Json.JsonReaderException,Message=Invalid character after parsing property name. Expected ':' but got: ,. Path 'result', line 1, position 15740073.,Source=Newtonsoft.Json,'",
"failureType": "UserError",
"target": "REST-API-ServiceNow"
}
有人可以帮我吗?
提前致谢!
最佳答案
1.Error occurred when deserializing source JSON data. Please check if the data is in valid JSON object format. 2.Message=Invalid character after parsing property name. Expected ':' but got: ,.
我认为错误详细信息表明 ADF 无法反序列化您的源数据,因为它不是标准 JSON 格式。非法 JSON 数据无法通过 ADF 复制事件。
我无法在我这边重现您的问题,因为我无法触及您的源数据。但是,我建议您使用 WEB Activity在执行复制事件之前调用 REST API。并收集Web Activity的输出(来自REST API的响应)并将它们存储在其他住宅中。以便您每次都可以检查您的源数据是否合法。
<小时/>我的想法如下:
1.配置Web Activity来调用您的REST API,然后您可以从源数据中获取响应。
2.配置一个 Function App Activity 来记录上述 Web Activity 的输出。
Body
应设置 Web Activity 的输出:@activity('Web1').output
,然后将其记录到函数应用程序中。一些示例函数代码如下:
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace FunctionAppStoreCSV
{
public static class Function2
{
[FunctionName("Function2")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
log.LogInformation(requestBody);
return requestBody != null
? (ActionResult)new OkObjectResult($"Log Successfully")
: new BadRequestObjectResult("Please pass output in the request body");
}
}
}
我在本地进行了测试,您可能会看到类似以下的日志数据:
如果在门户中,您可以在 KUDU url 上查看日志:D:\home\LogFiles\Application\Functions\function\Function2>
3.在复制事件之前将它们连接到 ADF 中。
提示:
我的方式可以节省 azure 存储的费用,我只是记录数据,以便您可以检查数据是否遵循严格的格式。当然,您可以将它们存储在 blob 存储中。只需编写代码即可将 Body
数据存储到 Blob 存储中,如您在 Azure Function 应用程序中所需的那样。
关于json - Azure 数据工厂 V2 复制数据问题 - 错误代码 : 2200,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58820399/