简体   繁体   中英

Im getting the error "{"error":{"code":null,"message":"The URI is malformed."}}", when "&" is passed in the api below

def get_dw_dim_channel_by_channel(self, channel):
    url = 'db-warehouse-dw/dim_channel?$filter=channel_name eq \'{}\''.format(channel)
    print ("debug: url = {}{}".format(self.host, url))
    return self.get(url, headers=self.headers, auth=self.auth)

Here the value for channel_name is "WDC Kitchen & Bath Center".

The error after executing the above code:

{"error":{"code":null,"message":"The URI is malformed."}}

What must I do to fix it?

The ampersand needs to be percent-encoded. Try to use:

channel = channel.replace("&", "%26")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM