Forum Discussion

Suraj_Ncircle's avatar
Suraj_Ncircle
Frequent Visitor
1 year ago
Solved

Why is %29 in a URL Encode to ) During a Request?

Hi Everyone,

I encountered an issue while working with a direct download URL in Power Query using the Web.Contents function. The URL contains an encoded value %29 (which represents a closing parenthesis ) in URL encoding). However, when the request is sent, the %29 is automatically converted to ) as observed in Fiddler.

Example:

URL I Want to Hit:
https://cdn.Domain.com/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlO_dmVyc2lvbj0x/output/Resource/3D%20View/2_%20%EC%84%B1%EB%8A%A5%20%EA%B5%AC%EB%B6%84%29%20S-A_%20%EA%B5%AC%EC%A1%B0%2014159939/2_%20%EC%84%B1%EB%8A%A5%20%EA%B5%AC%EB%B6%84%29%20S-A_%20%EA%B5%AC%EC%A1%B0?{cookies Appended}

What I See in Fiddler:
https://cdn.Domain.com/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlO_dmVyc2lvbj0x/output/Resource/3D%20View/2_%20%EC%84%B1%EB%8A%A5%20%EA%B5%AC%EB%B6%84)%20S-A_%20%EA%B5%AC%EC%A1%B0%2014159939/2_%20%EC%84%B1%EB%8A%A5%20%EA%B5%AC%EB%B6%84)%20S-A_%20%EA%B5%AC%EC%A1%B0?{cookies Appended}

It appears that %29 is being decoded to ) before the request is sent. This behavior causes 403 issues because the server expects the %29 to remain encoded.

 

My Questions:

  1. Why is the %29 automatically decoded to ) in the request?
  2. Is there a way to ensure %29 remains encoded in the request when using Power Query?
  3. Are there any workarounds to handle this issue if the server strictly expects %29 instead of )?

Any insights or solutions would be greatly appreciated!

Thanks!

 

 

 

  • v-csrikanth's avatar
    v-csrikanth
    1 year ago

    Hi Suraj_Ncircle 
    While encoding the entire URL using Uri.EscapeDataString in PQ is problematic because Web.Contents expects a valid absolute URL and may not properly handle fully encoded URLs.
    However, we can work around this by constructing the request in a way that ensures encoding remains intact.
    Manually encoding the entire URL:
    ***************************************************************
    let
    BaseUrl = "https://cdn.Domain.com/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlO_dmVyc2lvbj0x/output/Resource/3D%20View/2_%2...",
    Cookies = "your_cookie_data",
    EncodedUrl = Uri.EscapeDataString(BaseUrl), // Encode the entire URL
    QueryResponse = Web.Contents(EncodedUrl & Cookies, [Headers=[#"Accept"="application/json"]])
    in
    QueryResponse
    ***************************************************************
    After giving a try if still the issue persists. Could you please follow below link to raise a support ticket
    https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket 

    If the above information helps you, please give us a Kudos and marked the reply Accept as a Solution.

    Thanks,
    Cheri Srikanth

11 Replies