简体   繁体   English

如何将带有查询字符串的 url 作为 api 参数传递?

[英]How to pass url with query string as an api parameter?

I am curently integrating the api to my application.我目前正在将 api 集成到我的应用程序中。 One of the parameter is content_url which is a valid HTML URL for content.其中一个参数是 content_url,它是内容的有效 HTML URL。 How to I pass whole url with query string?如何通过查询字符串传递整个 url?

API Endpoint parameter is located below. API Endpoint 参数位于下方。

            var contentUrl
            = "https://www.finnet.com.tr/CMS/OSMANLIMENKULTEST/MailSablon/RaporPaylasimHtml/OSMANLIKP/FXBULTEN/2020-01-20/null";
        var url = "https://campaigns.zoho.com/api/v1.1/createCampaign?" +
                  "resfmt=json&" +
                  "campaignname=Campaign12&" +
                  "from_email=mert.metin@finnet.gen.tr&" +
                  "subject=Test Create Campaign 11&" + 
                  "list_details=%7Bd6ef220cc42b50d7ddf3236cbb9b8847894375f7a7d2d66f%3A%5B%5D%2Cd6ef220cc42b50d71438a8b019c635e5894375f7a7d2d66f%3A%5B%5D%7D&" +
                  "content_url=" + contentUrl;

Content url is https://www.finnet.com.tr/CMS/OSMANLIMENKULTEST/MailSablon/RaporPaylasimHtml?SiteKod=OSMANLIKP&Kod=FXBULTEN&Tarih=2020-01-20 Content url is https://www.finnet.com.tr/CMS/OSMANLIMENKULTEST/MailSablon/RaporPaylasimHtml?SiteKod=OSMANLIKP&Kod=FXBULTEN&Tarih=2020-01-20

But I post url value, API gets the url until first & ampersand character.但是我发布了 url 值,API 得到 url 直到第一个 & 字符。 So remain parameter was missing.所以缺少剩余参数。 I need to pass whole url as a parameter.我需要将整个 url 作为参数传递。

Expected Result= https://www.finnet.com.tr/CMS/OSMANLIMENKULTEST/MailSablon/RaporPaylasimHtml?SiteKod=OSMANLIKP&Kod=FXBULTEN&Tarih=2020-01-20预期结果= https://www.finnet.com.tr/CMS/OSMANLIMENKULTEST/MailSablon/RaporPaylasimHtml?SiteKod=OSMANLIKP&Kod=FXBULTEN&Tarih=2020-20

Actual Result= https://www.finnet.com.tr/CMS/OSMANLIMENKULTEST/MailSablon/RaporPaylasimHtml?SiteKod=OSMANLIKP实际结果= https://www.finnet.com.tr/CMS/OSMANLIMENKULTEST/MailSablon/RaporPaylasimHtml?SiteKod=OSMANLIKP

My application is based on MVC and C# language.我的应用程序基于 MVC 和 C# 语言。 I also enclosed the url with double quotes but it is not work because of Api Response which is INVALID IMPORT URL.我还用双引号将 url 括起来,但它不起作用,因为 Api 响应是 INVALID IMPORT URL。

   You must encode the URL before passing as a parameter as

    myURL="myURL1?redir=" + Server.URLEncode("myURL2?id=4&user=test");

    It will create a correct URL without '?' and "&" characters as
  

    myURL= myURL1?redir=myURL2%3id%34%26user%3dtest

    To extract your redirect url from this encoded url you must use     
    HttpServerUtility.UrlDecode to turn it into a correct url again.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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