简体   繁体   English

使用 Azure 数据工厂从 REST API 获取数据

[英]GET data from REST API using Azure Data Factory

I am trying to get data from Pendo through REST API using Azure Data Factory.我正在尝试使用 Azure 数据工厂通过 REST API 从 Pendo 获取数据。 The PYTHON code for this activity is此活动的 PYTHON 代码是

import requests
url = "https://app.pendo.io/api/v1/aggregation"
data = "{\"response\":{\"mimeType\":\"application/json\"},\"request\":{\"pipeline\":[{\"source\":{\"guideEvents\":null,\"timeSeries\":{\"first\":\"1506977216000\",\"count\":-10,\"period\":\"dayRange\"}}}]}}"
headers = {
    'x-pendo-integration-key': "[add_your_pendo_int_key_here]",
    'content-type': "application/json"
}
response = requests.post(url, data = data, headers = headers)

How do I define the data part of the code through Azure Data Factory?如何通过Azure数据工厂定义代码的数据部分? I've put the content-type and x-pendo-integration-key in the additional headers.我已将 content-type 和 x-pendo-integration-key 放在附加标题中。

You can use HTTP Connector to retrieve data from HTTP endpoint.您可以使用 HTTP 连接器从 HTTP 端点检索数据。 This HTTP connector is supported for the following activities:此 HTTP 连接器支持以下活动:

  • Copy activity with supported source/sink matrix使用支持的源/汇矩阵复制活动
  • Lookup activity You can copy data from an HTTP source to any supported sink data store.查找活动 您可以将数据从 HTTP 源复制到任何受支持的接收器数据存储。 For a list of data stores that Copy Activity supports as sources and sinks, see Supported data stores and formats .有关 Copy Activity 支持作为源和接收器的数据存储列表, 请参阅支持的数据存储和格式

Note : To test an HTTP request for data retrieval before you configure the HTTP connector in Data Factory, learn about the API specification for header and body requirements. Note : To test an HTTP request for data retrieval before you configure the HTTP connector in Data Factory, learn about the API specification for header and body requirements. You can use tools like Postman or a web browser to validate.您可以使用 Postman 或 web 浏览器等工具进行验证。

https://docs.microsoft.com/en-us/azure/data-factory/connector-http https://docs.microsoft.com/en-us/azure/data-factory/connector-http

Here is a sample Custom activity for POST:以下是 POST 的示例自定义活动:

{
    "name": "HttpSourceDataInput",
    "properties": {
        "type": "HttpFile",
        "linkedServiceName": {
            "referenceName": "<HTTP linked service name>",
            "type": "LinkedServiceReference"
        },
        "typeProperties": {
            "relativeUrl": "<relative url>",
            "requestMethod": "Post",
            "requestBody": "<body for POST HTTP request>"
        }
    }
}

You can check ADF related samples here .Also find this for additional reference.您可以在此处查看 ADF 相关示例。也可以在此处找到示例以获取更多参考。 Hope it helps.希望能帮助到你。

Problem solved.问题解决了。 The data part of the PYTHON code(with out the \ ) is put in the Request Body of Copy Activity in Azure Data Factory and the Request Method is POST. PYTHON代码的数据部分(不带\ )放在Azure数据工厂的复制活动的请求体中,请求方法为POST。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM