verified-sources icon indicating copy to clipboard operation
verified-sources copied to clipboard

rest_api: passing value for path parameters not working as expected

Open francescomucio opened this issue 1 year ago • 3 comments

dlt version

0.4.12

Source name

rest_api

Describe the problem

Configuring an endpoint like this:

            {
                "name": "user",
                "endpoint": {
                    "path": "users/{id}",
                    "params": {
                        "id": 2,
                    },
                },
            },

Is returing an url built like this:

https://reqres.in/api/users/%7Bid%7D?id=2

the expected is

https://reqres.in/api/users/2

Expected behavior

No response

Steps to reproduce

I am using the reqres.in testing api, with the following configuration:

import dlt
from rest_api import RESTAPIConfig, rest_api_source, RESTClient, DltResource


def load_reqres_in():
    reqres_in_config: RESTAPIConfig = {
        "client": {
            "base_url": "https://reqres.in/api",
        },
        "resources": [
            {
                "name": "user",
                "endpoint": {
                    "path": "users/{id}",
                    "params": {
                        "id": 2,
                    },
                },
            },
        ],
    }

    pipeline = dlt.pipeline(
        pipeline_name="reqres_in",
        destination="duckdb",
    )

    reqres_in_source = rest_api_source(reqres_in_config)

    load_info = pipeline.run(reqres_in_source)
    print(load_info)


if __name__ == "__main__":
    load_reqres_in()

How you are using the source?

I run this source in production.

Operating system

Linux

Runtime environment

Local

Python version

3.10.9

dlt destination

duckdb

Additional information

No response

francescomucio avatar Jun 14 '24 09:06 francescomucio