Get full url from shorten url in C#.net - c#

I am developing one application where I need capture basic detail like title, description and images of website based on url provided by user.
But user may be enter www.google.com insted of http://www.google.com but C#.net code failed to retrieve data for "www.google.com" through below code
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
request.Method = WebRequestMethods.Http.Get;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
String responseString = reader.ReadToEnd();
response.Close();
and found error like "Invalid URI: The format of the URI could not be determined."
So do know any technique to found full url based on shorten url.
for ex. google.com or www.google.com
Expected output : http://www.google.com or https://www.google.com
PS : I found online web tool (http://urlex.org/) that will return full url based on shorten url
Thanks in advance.

You can use UriBuilder to create a URL with HTTP as default scheme:
UriBuilder urb = new UriBuilder("www.google.com");
Uri uri = urb.Uri;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Get;
string responseString;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
responseString = reader.ReadToEnd();
}
}
If your URL contains a scheme, it will use that one instead of the default HTTP scheme. I have also used using to release all unmanaged resources.

So do know any technique to found full url based on shorten url.
I may have misunderstood your issue here but can't you just append "http://" if it's missing?
string url = "www.google.com";
if (!url.StartsWith("http"))
url = $"http://{url}";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
request.Method = WebRequestMethods.Http.Get;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
String responseString = reader.ReadToEnd();
}
This is basically what a web browser does when you don't specify any protocol.

Related

How to use get_video_info Youtube

I'm trying to develop a Youtube downloader.I need video mp4 stream urls and im trying to use get_video info check my source code
WebRequest req = HttpWebRequest.Create("https://www.youtube.com/get_video_info?video_id=" + videoid +"&el=embedded&ps=default&eurl=&gl=US&hl=en");
WebResponse webResp = req.GetResponse();
StreamReader sr = new StreamReader(webResp.GetResponseStream(), System.Text.Encoding.UTF8);
string data = sr.ReadToEnd();
sr.Close();
webResp.Close();
This codes always get just a part of data maybe half.After decoding data just looks like this
length_seconds=459&sffb=True&no_get_video_log=1&hl=en_US&vmap=<?xml+version="1.0"+encoding="UTF-8"?><vmap:VMAP+xmlns:vmap="http://www.iab.net/videosuite/vmap"+xmlns:yt="http://youtube.com"+version="1.0"><vmap:AdBreak+breakType="linear"+timeOffset="start"><vmap:AdSource+allowMultipleAds+=+"false"><vmap:VASTData><VAST+version="3.0"><Ad><Wrapper><AdSystem+version="1">YT:AdSense</AdSystem><VASTAdTagURI><![CDATA[https://googleads.g.doubleclick.net/pagead/ads?ad_type=text_image&channel=Vertical_1021+Vertical_1036+Vertical_1408+Vertical_211+Vertical_36+Vertical_590+Vertical_613+afv_overlay+afv_user_id_IO0szsIo5AKIFmbbhfxFqw+afv_user_lundgrenrob+invideo_overlay_480x70_cat10+yt_cid_679125+yt_mpvid_xxV6hpjhJlzWVUm7+yt_no_360+yt_no_3pas+yt_no_ap+yt_no_cp+yt_no_wa+ytdevice_1+ytdevicever_1.20170712+ytel_embedded+ytps_default&client=ca-pub-6219811747049371&dbp=ChZoWFduSWZZN2VpcG9CaWVYWnBPSndBEAEgASgA&description_url=http://www.youtube.com/video/rzkoQFbzmOk&eid=148648206&hl=en&host=ca-host-pub-7533488853144487&ht_id=5547539&loeid=9413138,9422596,9431012,9434289,9441394,9444433,9444893,9450707,9451825,9460350,9463578,9465813,9475121,9475579,9476699,9478199,9478523,9479324,9480114,9480538,9481125,9481317,9482504,9482602,9482851,9483147,9483258,9483501&osd=2&pucrd=CgYIABAAGAA&sdki=18803DAD&url=http://www.youtube.com/video/rzkoQFbzmOk&videoad_start_delay=0&v_p=JY0c2kM=&ytdevice=1&ytdevicever=1.20170712&yt_pt=APb3F2_FMmSD8mG8PMmMq7urTSbmCkJ0Bga4WDpKEQV0vAboVlPPijEHbExGYSXuMBmFcOJpCrpa2LhYnrkbgQbnWXXOarZjCKizS68OiIqOlB2GrZui5-ggUQ6aT7w6CaS_ifnYBnZXHpId9iX76vg6ufeyBrm43Pn8XtzfKSqvqvC1W8CRVv5me3zlMAU8-o1WblaDrL0g1b7SL7ot8DDGof6LRYQvNLPRCMZ6cjjIRMd62t7yetC6yMM2gjL_wZnSM_yKWhGZZgCWLQpIGY40tHARFRtOCCQsri5ttw&yt_vis=0]]></VASTAdTagURI><Impression><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=2&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&asr=CgA&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_len=[AD_LEN]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&aqi=]]></Impression><Error><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=5&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_len=[AD_LEN]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&blocking_error=[BLOCKING_ERROR]&error_msg=[ERROR_MSG]&ima_error=[IMA_ERROR]&internal_id=[INTERNAL_ID]&error_code=[YT_ERROR_CODE]&aqi=]]></Error><Creatives><Creative><NonLinearAds><TrackingEvents><Tracking+event="close"><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=4&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&i_x=[I_X]&i_y=[I_Y]&aqi=]]></Tracking></TrackingEvents><NonLinear><NonLinearClickTracking><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=6&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_len=[AD_LEN]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&i_x=[I_X]&i_y=[I_Y]&aqi=[AQI]]]></NonLinearClickTracking></NonLinear></NonLinearAds></Creative></Creatives><Extensions><Extension+type="waterfall"+fallback_index="1"/><Extension+type="activeview"><CustomTracking><Tracking+event="viewable_impression"><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=11&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&format=[FORMAT_NAMESPACE]_[FORMAT_TYPE]_[FORMAT_SUBTYPE]&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]&ad_cpn=[AD_CPN]&ad_id=[AD_ID]&ad_len=[AD_LEN]&ad_mt=[AD_MT]&ad_sys=[AD_SYS]&ad_v=[AD_V]&aqi=]]></Tracking></CustomTracking></Extension></Extensions></Wrapper></Ad></VAST></vmap:VASTData></vmap:AdSource><vmap:TrackingEvents><vmap:Tracking+event="error"><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=1&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]]]></vmap:Tracking></vmap:TrackingEvents><vmap:Extensions><vmap:Extension+type="YouTube"><yt:BreakProperty+break_type="BREAK_TYPE_PRE_ROLL"/></vmap:Extension></vmap:Extensions></vmap:AdBreak><vmap:AdBreak+breakType="linear"+timeOffset="end"><vmap:AdSource+allowMultipleAds+=+"false"><vmap:AdTagURI><![CDATA[https://www.youtube.com/get_midroll_info?ei=om5qWfj6NYL_WNjYpIAD&m_pos=-1&index=1&token=AHArUmCi7IgSemIU1zQ6mZwxAcXsVLNJRz6p3BHXmckVo5VKctFqc4x6ksXsbH17HJT9kg5rEKPeTdDjb8Futt8whSRi64lqWuqukgtn7FROGCnEcb9nflpkqnys0RH7G3Felht1tx5IPbpnRh6iSc3pfhsvMMPvQRMUmRuozIyIZp7xVwhrQeYReh0leKubfaqXPRTWIGKf2u-2G082rpE8bhBTdY-ZINFWZXRhW3QAe2N9VTy4wbPGvNo7KAQ2qdBIoMJoJ9-LKEkHoensql4QkA8b3tQb9lJylNiD7N6DG4OQM0gGUrTW0xabLI-NLmeGOeRTCKr-&ad_block=[AD_BLOCK]&cpn=[CPN]&lact=[LACT]&tsla=[TSLA]&vis=[VIS]&c=WEB&cver=1.20170712]]></vmap:AdTagURI></vmap:AdSource><vmap:TrackingEvents><vmap:Tracking+event="error"><![CDATA[https://www.youtube.com/api/stats/ads?ver=2&ns=1&event=1&device=1&content_v=rzkoQFbzmOk&el=embedded&ei=om5qWfj6NYL_WNjYpIAD&devicever=1.20170712&break_type=[BREAK_TYPE]&conn=[CONN]&cpn=[CPN]&lact=[LACT]&m_pos=[MIDROLL_POS]&mt=[MT]&p_h=[P_H]&p_w=[P_W]&rwt=[RWT]&sdkv=[SDKV]&slot_pos=[SLOT_POS]&vis=[VIS]&vol=[VOL]&wt=[WT]]]></vmap:Tracking></vmap:TrackingEvents><vmap:Extensions><vmap:Extension+type="YouTube"><yt:BreakProperty+break_type="BREAK_TYPE_POST_ROLL"/></vmap:Extension></vmap:Extensions></vmap:AdBreak><vmap:Extensions><vmap:Extension+type="YouTube"><TrackingDecoration+match="^https?://((([a-z][a-z0-9.-]*\.)?(youtube|corp\.google).com/api/stats/ads)|((www\.)?youtube\.com/pagead/psul))"+headers="device,user"/><TrackingMacro+match="^https?://(secure\-uat\-dpr\.imrworldwide|secure\-gg\.imrworldwide|g\.scorecardresearch)\.com/"+macros="device_id"/><RegexUriMacroValidator><MacroToRegexUris+macro="NIELSEN_DEVICE_ID"><RegexUri+value="^https?://(secure\-uat\-dpr\.imrworldwide|secure\-gg\.imrworldwide|g\.scorecardresearch)\.com/"/></MacroToRegexUris><MacroToRegexUris+macro="COMSCORE_DEVICE_ID"><RegexUri+value="^https?://(secure\-uat\-dpr\.imrworldwide|secure\-gg\.imrworldwide|g\.scorecardresearch)\.com/"/></MacroToRegexUris><MacroToRegexUris+macro="MOAT_INIT"><RegexUri+value="^https?://yts\.moatads\.com"/><RegexUri+value="^https?://yts-testing\.moatads\.com"/><RegexUri+value="^https?://pagead2\.googlesyndication\.com/pagead/gen_204"/></MacroToRegexUris><MacroToRegexUris+macro="MOAT_VIEWABILITY"><RegexUri+value="^https?://[^.]*\.moatads\.com"/><RegexUri+value="^https?://pagead2\.googlesyndication\.com/pagead/gen_204"/><RegexUri+value="^https?://pubads\.g\.doubleclick\.net"/></MacroToRegexUris><MacroToRegexUris+macro="IAS_VIEWABILITY"><RegexUri+value="^https?://pm\.adsafeprotected\.com/youtube"/><RegexUri+value="^https?://pm\.test-adsafeprotected\.com/youtube"/><RegexUri+value="^https?://pagead2\.googlesyndication\.com/pagead/gen_204"/><RegexUri+value="^https?://pubads\.g\.doubleclick\.net"/></MacroToRegexUris><MacroToRegexUris+macro="DV_VIEWABILITY"><RegexUri+value="^https?://e[0-9]+\.yt\.srs\.doubleverify\.com"/><RegexUri+value="^https?://pagead2\.googlesyndication\.com/pagead/gen_204"/><RegexUri+value="^https?://pubads\.g\.doubleclick\.net"/></MacroToRegexUris><MacroToRegexUris+macro="GOOGLE_VIEWABILITY"><RegexUri+value="^https?://pagead2\.googlesyndication\.com"/><RegexUri+value="^https?://pubads\.g\.doubleclick\.net"/><RegexUri+value="^https?://googleads\.g\.doubleclick\.net"/><RegexUri+value="^https?://([a-z0-9]+\.)*youtube\.com"/><RegexUri+value="^https?://ad[\.-]([a-z0-9]+\.){0,1}doubleclick\.net"/><RegexUri+value="^https?://ade\.googlesyndication\.com"/></MacroToRegexUris></RegexUriMacroValidator></vmap:Extension></vmap:Extensions></vmap:VMAP>&encoded_ad_safety_reason=CgA&thumbnail_url=https://i.ytimg.com/vi/rzkoQFbzmOk/default.jpg&innertube_api_key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&atc=a=3&b=32vy80AGa-Bgh5X78MGIbmu2Kto&c=1500147363&d=1&e=rzkoQFbzmOk&c3a=26&c1a=1&c6a=1&hh=1HDgx0VAJl0SXzxb45QsrH_lAKVbaJ_K7iaF7J_ogxg&iv_load_policy=1&fade_out_start_milliseconds=0&instream_long=False&avg_rating=4.95149946213&of=hXWnIfY7eipoBieXZpOJwA&ismb=4450000&xhr_apiary_host=youtubei.youtube.com&loeid=9413138,9422596,9431012,9434289,9441394,9444433,9444893,9450707,9451825,9460350,9463578,9465813,9475121,9475579,9476699,9478199,9478523,9479324,9480114,9480538,9481125,9481317,9482504,9482602,9482851,9483147,9483258,9483501&enablecsi=1&account_playback_token=QUFFLUhqbG5Ta1k2bjVZNXE1S1RjeXJma0dYOVhJTlgtUXxBQ3Jtc0trRmxkREVqN1pxcjVPNTB3UUFxOG13RTNoVG1UQ0t4bDFNM3ZyQXhHbGtRQ1FyaWNYSGttZXlVTktEeGc3clQwNkFBNy1Bb08zTEJ6TDZNYkxWN2dwR1JfTWlQbnEyTE9DdDdNNUNGT1pTX3BrZU5aTQ==&fade_in_start_milliseconds=-3000&relative_loudness=0.760999679565&afv_ad_tag=https://googleads.g.doubleclick.net/pagead/ads?ad_type=text_image&channel=Vertical_1021+Vertical_1036+Vertical_1408+Vertical_211+Vertical_36+Vertical_590+Vertical_613+afv_overlay+afv_user_id_IO0szsIo5AKIFmbbhfxFqw+afv_user_lundgrenrob+invideo_overlay_480x70_cat10+yt_cid_679125+yt_mpvid_xxV6hpjhJlzWVUm7+yt_no_360+yt_no_3pas+yt_no_ap+yt_no_cp+yt_no_wa+ytdevice_1+ytdevicever_1.20170712+ytel_embedded+ytps_default&client=ca-pub-6219811747049371&dbp=ChZoWFduSWZZN2VpcG9CaWVYWnBPSndBEAEgASgA&description_url=http://www.youtube.com/video/rzkoQFbzmOk&eid=148648206&hl=en&host=ca-host-pub-7533488853144487&ht_id=5547539&loeid=9413138,9422596,9431012,9434289,9441394,9444433,9444893,9450707,9451825,9460350,9463578,9465813,9475121,9475579,9476699,9478199,9478523,9479324,9480114,9480538,9481125,9481317,9482504,9482602,9482851,9483147,9483258,9483501&osd=2&pucrd=CgYIABAAGAA&sdki=18803DAD&url=http://www.youtube.com/video/rzkoQFbzmOk&v_p=JY0c2kM=&ytdevice=1&ytdevicever=1.20170712&yt_pt=APb3F2_FMmSD8mG8PMmMq7urTSbmCkJ0Bga4WDpKEQV0vAboVlPPijEHbExGYSXuMBmFcOJpCrpa2LhYnrkbgQbnWXXOarZjCKizS68OiIqOlB2GrZui5-ggUQ6aT7w6CaS_ifnYBnZXHpId9iX76vg6ufeyBrm43Pn8XtzfKSqvqvC1W8CRVv5me3zlMAU8-o1WblaDrL0g1b7SL7ot8DDGof6LRYQvNLPRCMZ6cjjIRMd62t7yetC6yMM2gjL_wZnSM_yKWhGZZgCWLQpIGY40tHARFRtOCCQsri5ttw&yt_vis=0&is_listed=1&cafe_experiment_id=148648206&mpvid=xxV6hpjhJlzWVUm7&cver=1.20170712&ptchn=IO0szsIo5AKIFmbbhfxFqw&fade_in_duration_milliseconds=1000&video_id=rzkoQFbzmOk&allow_html5_ads=1&dbp=Ch4KFmhYV25JZlk3ZWlwb0JpZVhacE9Kd0EQASABKAAQARgC&as_launched_in_country=1&iv_invideo_url=https://www.youtube.com/annotations_invideo?cap_hist=1&video_id=rzkoQFbzmOk&client=1&ei=om5qWfj6NYL_WNjYpIAD&csi_page_type=embed&keywords=rob+lundgren,cover,rock,metal,voice,vocal,live+vocal,lundgren,robin+lundgren,robin,nothing+else+matters,metallica,nem,nothing+else+matters+cover,acoustic+cover,n.e.m.,nem+cover,nothing+else+matters+acoustic+cover,metallica+cover,black+album&eventid=om5qWfj6NYL_WNjYpIAD&iv3_module=1&cr=US&root_ve_type=27240&cid=679125&fexp=9413138,9422596,9431012,9434289,9441394,9444433,9444893,9446364,9449243,9450707,9453897,9457141,9458230,9463578,9463594,9465813,9466793,9466795,9466797,9467217,9468797,9468799,9468805,9475121,9475579,9476699,9477080,9478199,9478523,9479324,9480114,9480475,9480538,9481125,9481317,9482504,9482602,9482648,9483147,9483258,9483501&innertube_context_client_version=1.20170712&author=Rob+Lundgren+Live+Vocals&cl=161729798&apiary_host=&allow_embed=1&ppv_remarketing_url=https://www.googleadservices.com/pagead/conversion/971134070/?backend=innertube&cname=1&cver=1_20170712&data=backend=innertube;cname=1;cver=1_20170712;dactive=None;dynx_itemid=rzkoQFbzmOk;ptype=ppv&label=iuZUCLmC72YQ9qiJzwM&ptype=ppv&token=1&swf_player_response=1&idpj=-9&fmt_list=22/1280x720/9/0/115,43/640x360/99/0/0,18/640x360/9/0/115,36/320x180/99/1/0,17/176x144/99/1/0&probe_url=https://r5---sn-q4f7sn76.googlevideo.com/videogoodput?id=o-AEixTmbMug2neWtp5U1Tb-21J9uJ59IBSUY4nJ2T0axm&source=goodput&range=0-4999&expire=1500150962&ip=95.14.68.108&ms=pm&mm=35&pl=24&nh=IgpwZjAyLmRmdzA2Kgs2Ni4xMTAuNTcuNQ&sparams=id,source,range,expire,ip,ms,mm,pl,nh&signature=147AA9BCF3169578802C44A7735BBB7926C37092.5C2597F4730C259D6DDCD8AAAB093C906A61E8AB&key=cms1&itct=CAEQu2kiEwj407O1hIzVAhWCPxYKHVgsCTAo6NQB&shortform=True&t=1&watermark=,https://s.ytimg.com/yts/img/watermark/youtube_watermark-vflHX6b6E.png,https://s.ytimg.com/yts/img/watermark/youtube_hd_watermark-vflAzLcD6.png&host_language=en&excluded_ads=46=14_14;59=14_14;61=1_3,2_3;64=14_14;65=15_2,15_2_1,15_2_4,17_2,17_2_1;84=1_1,1_2,1_2_1,1_3,2_2,2_2_1,2_2_4,2_3,15_2,15_2_1,15_2_4,17_2,17_2_1;89=2_2,15_2;94=15_2,15_2_1,15_2_4,17_2,17_2_1&title=NOTHING+ELSE+MATTERS+(Live+Vocal+&+Acoustic+Cover)&innertube_api_version=v1&allow_ratings=1&pltype=content&ptk=BroadbandTV_Music&csn=om5qWfj6NYL_WNjYpIAD&oid=3q6zKQH3OljiViOJ67PJOw&status=ok&allow_below_the_player_companion=True&loudness=-20.2390003204&ad_slots=0,-1&url_encoded_fmt_stream_map=type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"&itag=22&quality=hd720&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&lmt=1497979410219532&key=yt6&initcwndbps=556250&ipbits=0&mv=m&source=youtube&expire=1500168963&mn=sn-4g5e6nls&ratebypass=yes&mt=1500147287&pl=21&itag=22&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.570&mm=31&ip=95.14.68.108&signature=5E6066364965F76E6BC61052DC402531E5F319B2.A3BBC0015021650C424E050CD546133A23578F5B&sparams=dur,ei,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire,type=video/webm;+codecs="vp8.0,+vorbis"&itag=43&quality=medium&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&initcwndbps=556250&expire=1500168963&ratebypass=yes&clen=48022685&source=youtube&signature=771D35EFBBDC827F178E06B5B40372EA337A7E9F.6E06C0E37004690B1BF766340415170E296378ED&lmt=1497816143039353&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=43&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=0.000&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire,type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"&itag=18&quality=medium&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&initcwndbps=556250&expire=1500168962&ratebypass=yes&clen=42156239&source=youtube&signature=B20E84210DACE3069FC90109B0B4CCD229468AD2.C02B2E5EF9C162E4E2201DA9062571FC6D511010&lmt=1497979373206161&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=18&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.570&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire,type=video/3gpp;+codecs="mp4v.20.3,+mp4a.40.2"&itag=36&quality=small&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&initcwndbps=556250&expire=1500168963&clen=12684319&source=youtube&signature=384C051D8C33CEFB6E28062E460398765AB5680D.265633CF03B2E0ED7DC72A3C6F3B788D6E10FEF1&lmt=1497814285338647&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=36&ms=au&requiressl=yes&mime=video/3gpp&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.640&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,i...e&html5_subsegment_readahead_target_buffer_health_secs=0.5&report_promotes_terrorism_mobile_web=true&html5_disable_move_pssh_to_moov=true&html5_max_av_sync_drift=50&enable_playlist_multi_season=true&html5_suspend_manifest_on_pause=true&show_countdown_on_bumper=true&html5_always_reload_on_403=true&html5_repredict_interval_secs=0.0&signed_out_notifications_inbox=true&stop_using_ima_sdk_gpt_request_activity=true&kids_mqb_use_confirmed_safe_videos_only=true&html5_new_fallback=true&html5_subsegment_readahead_timeout_secs=2.0&android_native_live_enablement=true&html5_adjust_effective_request_size=true&html5_hopeless_mode_request_size_secs=40&mpu_visible_threshold_count=2&vss_dni_delayping=0&disable_new_pause_state3=true&html5_disable_non_contiguous=true&flex_theater_mode=true&lugash_header_warmup=true&html5_min_readbehind_cap_secs=0&youtubei_for_web=true&disable_reporting_html5_no_vast_ads_as_error=true&html5_vp9_live_whitelist=false&html5_suspended_state=true&html5_connect_timeout_secs=7.0&web_player_flash_fallback_killswitch=true&use_push_for_desktop_live_chat=true&html5_min_secs_between_format_selections=8.0&gapi_hint_params=m;/_/scs/abc-static/_/js/k=gapi.gapi.en.BznCEch7yrY.O/m=__features__/rt=j/d=1/rs=AHpOoo89FbxkNsIBOnpzYJliP4nzTuPXPg&view_count=138746&gut_tag=/4061/ytunknown/main&core_dbp=ChZoWFduSWZZN2VpcG9CaWVYWnBPSndBEAEgASgA&midroll_freqcap=600.0&apply_fade_on_midrolls=True&ad3_module=1&iv_allow_in_place_switch=1&adaptive_fmts=init=0-715&itag=137&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=142261087&source=youtube&signature=A81AFBC28F4D37951D2A3CA9F9370EBC07E410E4.BD5547C59956D93C2B351B302DFD86E85451A0CA&lmt=1497979028342198&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=137&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=3799443&type=video/mp4;+codecs="avc1.640028"&lmt=1497979028342198&projection_type=1&quality_label=1080p&index=716-1827&size=1920x1080&clen=142261087,init=0-242&itag=248&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=158398468&source=youtube&signature=CCC0D2490353B0065E5829F151305D95AEDE55B9.7CF4D0EE40ACB221728D8AFDF084E6A5DFABCD98&lmt=1497816474083876&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=248&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.480&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=3123739&type=video/webm;+codecs="vp9"&lmt=1497816474083876&projection_type=1&quality_label=1080p&index=243-1842&size=1920x1080&clen=158398468,init=0-713&itag=136&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=79105869&source=youtube&signature=CDB118EDE7B63DDC9550F367E9F07830799655ED.D3EF922360819B481CF6ECC2763559AB0C3478AF&lmt=1497979016153211&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=136&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=2332623&type=video/mp4;+codecs="avc1.4d401f"&lmt=1497979016153211&projection_type=1&quality_label=720p&index=714-1825&size=1280x720&clen=79105869,init=0-242&itag=247&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=86507558&source=youtube&signature=93A41C597A00D1FA8E3D96781BF75C7DE64D9B1B.4DFE8C0F918A97505996A2CC7549D48D260BEBF5&lmt=1497816799001841&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=247&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.480&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=1767900&type=video/webm;+codecs="vp9"&lmt=1497816799001841&projection_type=1&quality_label=720p&index=243-1834&size=1280x720&clen=86507558,init=0-714&itag=135&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=44918449&source=youtube&signature=1B71C220D58B22A6971AADFB121760093B6B2C16.6FFD92B792E9A31D2F69B194D3ED2D0548E7F245&lmt=1497979015179453&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=135&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=1168568&type=video/mp4;+codecs="avc1.4d401e"&lmt=1497979015179453&projection_type=1&quality_label=480p&index=715-1826&size=854x480&clen=44918449,init=0-242&itag=244&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=42553772&source=youtube&signature=946B26FD19005B4A77678CF58359B091AA196647.AF6B0B71C672F97F34B50DDFCE58B184A86DD311&lmt=1497816797643690&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=244&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.480&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=891875&type=video/webm;+codecs="vp9"&lmt=1497816797643690&projection_type=1&quality_label=480p&index=243-1816&size=854x480&clen=42553772,init=0-714&itag=134&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=23508086&source=youtube&signature=1C0ECE53DF3F8D44509FB39E4E482A810BCC080E.916A6FF5E8B24D9B7A650A180C4984C15AB78E5B&lmt=1497979014659412&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=134&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=633970&type=video/mp4;+codecs="avc1.4d401e"&lmt=1497979014659412&projection_type=1&quality_label=360p&index=715-1826&size=640x360&clen=23508086,init=0-242&itag=243&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=23535825&source=youtube&signature=64D565D1DF5DE6B15DC5EE2EE615B2B69A27FD54.AA0F53B5E818B5653291E9755A2712E501028609&lmt=1497816797800637&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=243&ms=au&requiressl=yes&mime=video/webm&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.480&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=478817&type=video/webm;+codecs="vp9"&lmt=1497816797800637&projection_type=1&quality_label=360p&index=243-1788&size=640x360&clen=23535825,init=0-713&itag=133&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=13962368&source=youtube&signature=6CAFDFFD0FB4A1CCFDA3C54B7473FF2569EFE8AC.AEA43F8A56C9028D31932DBE1F7AF042E40099A7&lmt=1497979014440001&ipbits=0&mv=m&gir=yes&mt=1500147287&pl=21&itag=133&ms=au&requiressl=yes&mime=video/mp4&id=o-AIlu0RkrqMnKv9EvUKiHDF8r6kAlczSgWVujKgm6Rz4V&dur=458.520&mm=31&ip=95.14.68.108&mn=sn-4g5e6nls&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&bitrate=286948&type=video/mp4;+codecs="avc1.4d4015"&lmt=1497979014440001&projection_type=1&quality_label=240p&index=714-1825&size=426x240&clen=13962368,init=0-241&itag=242&fps=25&xtags=&url=https://r1---sn-4g5e6nls.googlevideo.com/videoplayback?ei=om5qWfj6NYL_WNjYpIAD&key=yt6&keepalive=yes&initcwndbps=556250&expire=1500168963&clen=12769212&source=youtube&signature=A49774FB936FBACCFF7993E6644AB6D35B87F6
You see its not full data I need from get_video_info.Its just a part of it.How can i solve this?
Use HttpClient it is much simpler than HttpWebRequest
using (var client = new HttpClient()) {
var response = await client.GetAsync(url);
string content = await response.Content.ReadAsStringAsync();
}
HttpClient is the best of both worlds (i.e. WebClient and HttpWebRequest)

How do I post to GitHub API v3

I am using GitHub API v3 with C#. I am able to get the access token and using that I am able to get the user information and repo info.
But when I try to create a new repo I am getting the error as Unauthorized.
I am using HttpWebRequest to post data, which can be seen below. Please suggest me some C# sample or sample code.
(..)string[] paramName, string[] paramVal, string json, string accessToken)
{
HttpWebRequest req = WebRequest.Create(new Uri(url)) as HttpWebRequest;
req.Method = "POST";
req.ContentType = "application/json";
StreamWriter writer = new StreamWriter(req.GetRequestStream());
writer.Write(json);
writer.Close();
string result = null;
using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
{
StreamReader reader =
new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();
}(..)
Note: I am not sure where i need to add the accesstoken. I have tried in headers as well as in the url, but none of them works.
Are you using the C# Github API example code? I would look at that code to see if it does what you need.
You can use basic auth pretty easily by just adding auth to the request headers:
request.Headers.Add("Authorization","Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(username +":"+password)));
Sorry havent used the access token stuff yet.
You need to add this token here:
req.UserAgent = "My App";
req.Headers.Add("Authorization", string.Format("Token {0}", "..token..");
Try
rec.Credentials = CredentialCache.DefaultCredentials;
or use non-default credentials.
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx

C# WebRequest won't work with this link from LinkShare

This is driving me a bit nuts. I am trying to do something quite simple, and I have done it many times before. Just trying to call a REST API.
I am trying to call GetMessage with endpoint = "http://feed.linksynergy.com/productsearch?token=717f8c8511725ea26fd5c3651f32ab187d8db9f4b208be781c292585400e682d&keyword=DVD", and it keeps returning empty string. If I pass it any other valid URL, it will work. But if I just copy and paste the original URL into the web browser, it returns fine!
Can any smart developer tell me what's going on?
Code below. Thanks in advance.
James
public string GetMessage(string endPoint)
{
HttpWebRequest request = CreateWebRequest(endPoint);
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if (response.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("POST failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
using (var responseStream = response.GetResponseStream())
{
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
return responseValue;
}
}
private HttpWebRequest CreateWebRequest(string endPoint)
{
var request = (HttpWebRequest)WebRequest.Create(endPoint);
request.Method = "GET";
request.ContentLength = 0;
request.ContentType = "text/xml";
return request;
}
Not sure why your setting ContentLength/ContentType - that is generally for HTTP POST, where there is a request body for which you write data to via a stream.
This is a HTTP GET, so there is no request body. (just URI w/ query string)
This should work:
using System;
using System.IO;
using System.Net;
using System.Text;
// Create the web request
HttpWebRequest request = WebRequest.Create("http://www.someapi.com/") as HttpWebRequest;
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
// Console application output
Console.WriteLine(reader.ReadToEnd());
}
EDIT
#Gabe is also quite right - try this on another computer, that is isn't behind any kind of firewall/proxy server.
My work PC was behind a proxy server, so in order to make REST-based HTTP calls, i needed to do this:
var proxyObject = new System.Net.WebProxy("http://myDomain:8080/", true);
System.Net.WebRequest req = System.Net.WebRequest.Create("http://www.someapi.com/");
req.Proxy = proxyObject;
proxyObject.Credentials = New System.Net.NetworkCredential("domain\username","password")

How to get json response using system.net.webrequest in c#?

I need to get json data from an external domain.
I used WebRequest to get the response from a website.
Here's the code:
var request = WebRequest.Create(url);
string text;
var response = (HttpWebResponse) request.GetResponse();
using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
Does anyone know why I can't get the json data?
Some APIs want you to supply the appropriate "Accept" header in the request to get the wanted response type.
For example if an API can return data in XML and JSON and you want the JSON result, you would need to set the HttpWebRequest.Accept property to "application/json".
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUri);
httpWebRequest.Method = WebRequestMethods.Http.Get;
httpWebRequest.Accept = "application/json";
You need to explicitly ask for the content type.
Add this line:
request.ContentType = "application/json; charset=utf-8";At the appropriate place

WebRequest to connect to the Wikipedia API

This may be a pathetically simple problem, but I cannot seem to format the post webrequest/response to get data from the Wikipedia API. I have posted my code below if anyone can help me see my problem.
string pgTitle = txtPageTitle.Text;
Uri address = new Uri("http://en.wikipedia.org/w/api.php");
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
string action = "query";
string query = pgTitle;
StringBuilder data = new StringBuilder();
data.Append("action=" + HttpUtility.UrlEncode(action));
data.Append("&query=" + HttpUtility.UrlEncode(query));
byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
request.ContentLength = byteData.Length;
using (Stream postStream = request.GetRequestStream())
{
postStream.Write(byteData, 0, byteData.Length);
}
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream.
StreamReader reader = new StreamReader(response.GetResponseStream());
divWikiData.InnerText = reader.ReadToEnd();
}
You might want to try a GET request first because it's a little simpler (you will only need to POST for wikipedia login). For example, try to simulate this request:
http://en.wikipedia.org/w/api.php?action=query&prop=images&titles=Main%20Page
Here's the code:
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://en.wikipedia.org/w/api.php?action=query&prop=images&titles=Main%20Page");
using (HttpWebResponse response = (HttpWebResponse)myRequest.GetResponse())
{
string ResponseText;
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
ResponseText = reader.ReadToEnd();
}
}
Edit: The other problem he was experiencing on the POST request was, The exception is : The remote server returned an error: (417) Expectation failed. It can be solved by setting:
System.Net.ServicePointManager.Expect100Continue = false;
(This is from: HTTP POST Returns Error: 417 "Expectation Failed.")
I'm currently in the final stages of implementing an C# MediaWiki API which allows the easy scripting of most MediaWiki viewing and editing actions.
The main API is here: http://o2platform.googlecode.com/svn/trunk/O2%20-%20All%20Active%20Projects/O2_XRules_Database/_Rules/APIs/OwaspAPI.cs and here is an example of the API in use:
var wiki = new O2MediaWikiAPI("http://www.o2platform.com/api.php");
wiki.login(userName, password);
var page = "Test"; // "Main_Page";
wiki.editPage(page,"Test content2");
var rawWikiText = wiki.raw(page);
var htmlText = wiki.html(page);
return rawWikiText.line().line() + htmlText;
You seem to be pushing the input data on HTTP POST, but it seems you should use HTTP GET.
From the MediaWiki API docs:
The API takes its input through
parameters in the query string. Every
module (and every action=query
submodule) has its own set of
parameters, which is listed in the
documentation and in action=help, and
can be retrieved through
action=paraminfo.
http://www.mediawiki.org/wiki/API:Data_formats

Categories