Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
DevinL
Helper I
Helper I

Trouble with Request Body in Copy Data data flow

 
I'm connecting to a REST API through a POST request and trying to pass some parameters (filters) in the request body:
 

 

{
	"size": 100,
	"page": 1,
	"search": {
"date_limits": [
		    {
		        "field": "datetime",
		        "from": "2024-06-25 00:00:00",
		        "to": "2024-07-01 00:00:00"
		    }
		]
        	}
}

 

 

When I use this code in Postman (body -> raw), I'm able to pull back the correct filtered results.  When I put this same code into Microsoft Fabric in a Copy Data activity (Request body), it doesn't return the filtered results.

DevinL_0-1720560796043.png


I do not get an error, I just get the wrong unfiltered results. Also, I have to specify the size and page in the relative URL whereas in postman I can just include it in the body.

 

Any help is greatly appreciated!

4 REPLIES 4
Anonymous
Not applicable

HI @DevinL,

What REST API are you test? Can you please share some more detailed informations about these?

In additon, I'd like to suggest you to use trace tools to trace the request and detail contents from 'postman' and 'copy data activity' operations. Then you can compare traced cotnetns to ensure the differences between these requests from two methods.

How to collect a network trace | Microsoft Learn

Regards,

Xiaoxin Sheng

The REST API is for Sonar. I'm pulling back details for credits/debits/accounts/etc. and using the search feature in the sonar API to pull a specific date range. The purpose of doing it this way is to only bring in the new rows of data for each day rather than an entire replacement each day.


Anonymous
Not applicable

Hi @DevinL,

Have you try to put these processing in M queries with web connector and optional parameter and 'relative path'?

let
    //API endpoint
    url = "",
    // request headers
    headers = [#"Content-Type" = "application/json", #"Authorization" = "Bearer your_api_key"],
    //Relative path
    path = "credits/debits/accounts/xxxx",
    // query
    query = "{
    	'size': 100,
        'page': 1,
        'search': {
        'date_limits': [
                    {
                        'field': 'datetime',
                        'from': '2024-06-25 00:00:00',
                        'to': '2024-07-01 00:00:00'
                    }
                ]
        	}
    }",
    // Get the data from the API
    rawData = Web.Contents(url, [
        Headers = headers,
        RelativePath = path,
        Content = Text.ToBinary(query)
    ]),
    // Convert the JSON response into a table
    json = Json.Document(rawData),
    #"Converted to Table" = Record.ToTable(json)
in
    #"Converted to Table"

Using The RelativePath And Query Options With Web.Contents() In Power Query And Power BI M Code  
Regards,

Xiaoxin Sheng

Thanks for the reply.

Getting an error though: DataSource.Error: Web.Contents failed to get contents from 'https://apiaddressishere/search/credits' (422): Unprocessable Entity

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.