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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors