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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
bigshooTer
Frequent Visitor

Multiple Parameters in API URL - 422 Unprocessable Entity (power query for excel)

I'm trying to make an API I set up more dynamic so that I don't requery the same data everytime it refreshes.

 

I've set up the parameters and am able to pass the second parameter successfully, but when I try to set the 1st parameter in the middle of the URL, I get error "(422) unprocessable entity".  The two parameters I am trying to pass are start date & end date.  Both need to be in UNIX format, which is what I have as the default values.

 

For now, I've hard coded the 2nd parameter just to see if I can get the 1st parameter (StartDateUNIX) to pass successfully.

 

Can anyone suggest what I'm doing wrong?

 

let
Source = Json.Document(Web.Contents("https://api.baseurl.com/api/word/word/word/range?vs_currency=usd&from="&StartDateUNIX&"to=&1663288582")),
#"Converted to Table" = Record.ToTable(Source),
#"Expanded Value" = Table.ExpandListColumn(#"Converted to Table", "Value"),

 

 

I'm using this walkthrough as a reference.

https://wisedatadecisions.com/2021/05/03/parameterize-an-api-request-in-power-query/

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @bigshooTer 

 

Please refer to 422 Unprocessable Entity Explained - KeyCDN Support

 

The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415 (Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions.

 

Based on above explanation, I think your M code is correct. You may need to check the current value for parameter StartDateUNIX. Hard code two parameter values to test whether it returns the same 422 error when using the same start date and end date values. I guess probably the API sets a valid value range for these date parameters. If the value passed to the first parameter is out of the valid range, it may return this error. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @bigshooTer 

 

Please refer to 422 Unprocessable Entity Explained - KeyCDN Support

 

The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415 (Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions.

 

Based on above explanation, I think your M code is correct. You may need to check the current value for parameter StartDateUNIX. Hard code two parameter values to test whether it returns the same 422 error when using the same start date and end date values. I guess probably the API sets a valid value range for these date parameters. If the value passed to the first parameter is out of the valid range, it may return this error. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.