<\/HEAD>
Ik probeer een token te krijgen voor ArcGIS Online met c# (nou ja, meer specifiek SSIS). Ik heb een url die ik kan gebruiken en die goed werkt, en ik kan deze aanroepen en krijgen wat ik nodig heb in Chrome, maar het werkt niet via c# met een WebClient.<\/SPAN><\/P><\/P>Ik kan andere jsons ophalen via SSIS\/C# WebClient, maar om de een of andere reden NIET ArcGIS Online. De url werkt via Chrome, maar geeft geen antwoord via SSIS\/C# WebClient.<\/P>Mijn code (met client id\/secret\/credentials) is:<\/P><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">string<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> webResource <\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> <\/SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"https:\/\/mymaps.maps.arcgis.com\/sharing\/rest\/oauth2\/token?client_id=MYCLIENTID&client_secret=MYCLIENTSECRET&grant_type=client_credentials"<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">;<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"><\/SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">WebClient<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> wc <\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">=<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> <\/SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;">new<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"> <\/SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;">WebClient<\/SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">();<\/SPAN><SPAN class="" style="color:#303336;border:none;font-weight:inherit;font-size:13px;"><\/SPAN><SPAN class="" style="color:#101094;border:none;font-weight:inherit;font-size=13px">string<\/SPAN><SPAN class="" style="color:#303336;border:none;font-weight=inherit;font-size=13px"> json <\/SPAN><SPAN class="" style="color:#303336;border:none;font-weight=inherit;font-size=13px">=<\/SPAN><SPAN class="" style="color:#303336;border:none;font-weight=inherit;font-size=13px"> wc<\/SPAN><SPAN class="" style="color:#303336;border:none;font-weight=inherit;font-size=13px">.<\/SPAN><SPAN class="" style="color:#2b91af;border:none;font-weight=inherit;font-size=13px">DownloadString<\/SPAN><SPAN class="" style="color:#303336;border:none;font-weight=inherit;font-size=13px">(<\/SPAN><SPAN class="" style="color:#303336;border:none;font-weight=inherit;font-size=13px">webResource<\/SPAN><SPAN class="" style="color:#303336;border:none;font-weight=inherit;font-size=13px">);\n<\/SPAN><\/CODE><\/PRE><P style="color:#242729;background-color:#f9f8f6;border:none;margin-bottom:.5em">Ik zou dan de json parsen.<\/P><P style="color:#242729;background-color:#f9f8f6;border:none;margin-bottom:.5em">Momenteel krijg ik:<\/P><BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"><P><CODE><SPAN class="" style='color:#303336;border:none;font-weight=inherit;font-size=13px'>DTS <\/SPAN><SPAN class='' style='color:#2b91af;border:none;font-weight=inherit;font-size=13px'>Script<\/SPAN> <span style='color:#303336'>Task heeft een uitzondering ondervonden in gebruikerscode:</span> projectnaam:<span style='color:#303336'> ST_0a306cf2e1634509bea49b75b7d93265 </span> <span style='color:#2b91af'>Exception</span> is gegooid door het doel van een aanroep.<br> bij <span style='color:#2b91af'>System</span>.<span style='color:#2b91af'>RuntimeMethodHandle</span>.InvokeMethod(<span style='color:#2b91af'>Object</span> target, <span style='color:#2b91af'>Object</span>[] arguments, <span style='color:#2b91af'>Signature</span> sig, <span style='color:#2b91af'>Boolean</span> constructor) bij <span style='color:#2b91af'>System</span>.<span style='color:#2b91af'>Reflection</span>.<span style='color:#2b91af'>RuntimeMethodInfo</span>.UnsafeInvokeInternal(<span style='color:#2b91af'>Object</span> obj, <span style='color:#2b91af'>Object</span>[] parameters, <span style='color:#2b91af'>Object</span>[] ... #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;"> argumenten</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">)</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;"> bij </SPAN><SPAN class="" style="color: #2b91af; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">System</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">Reflection</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">RuntimeMethodInfo</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">.</SPAN><SPAN class="" style="color: #2b91af; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">Invoke</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">(</SPAN><SPAN class="" style="color: #2b91af; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">Object</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;"> obj</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">,</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">BindingFlags</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;"> invokeAttr</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;">,</SPAN><SPAN class="" style="color: #303336; rand: 0px; lettertype-dikte: overerven; lettergrootte: 13px;"> </SPAN><SPAN class="" style="color:#2b91af;border:none;font-weight:auto;font-size:auto">Binder</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto"> binder</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto">,</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto"> </SPAN><SPAN class="" style="color:#2b91af;border:none;font-weight:auto;font-size:auto">Object</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto">[] parameters</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto">,</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto"> </SPAN><SPAN class="" style="color:#2b91af;border:none;font-weight:auto;font-size:auto">CultureInfo</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto"> culture</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto">)</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto"> bij </SPAN><SPAN class="" style="color:#2b91af;border:none;font-weight:auto;font-size:auto">System</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto">.</SPAN><SPAN class="" style="color:#2b91af;border:none;font-weight:auto;font-size:auto">RuntimeType</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto">.</SPAN><SPAN class="" style="color:#2b91af;border:none;font-weight:auto;font-size:auto">InvokeMember</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto">(</SPAN><SPAN class="" style="color:#2b91af;border:none;font-weight:auto;font-size:auto">String</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto"> name</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto">,</SPAN><SPAN class="" style="color:#303336;border:none;font-weight:auto;font-size:auto"> </span><span class=''style=' color:#2b91af;'>BindingFlags</span> <span>bindingFlags, </span> <span> <span>Binder binder, </span> <span>Object target, </span> <span>Object[] providedArgs, </span> <span>ParameterModifier[] modifiers, </span> <span>CultureInfo culture, </span> <span>String[] namedParams)</span> <span>bij </span> <span>Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()</span>
Ik heb een applicatie gemaakt, zoals beschreven in https://developers.arcgis.com/labs/rest/get-an-access-token/
Een voorbeeld van de geretourneerde json (via Chrome) is:
{<span stijl='kleur :#7d2727 ;'> "access_token": "blahblahblahcrazywords.. "< / span > < / code > border: 0px; font-weight: inherit; font-size: 13px;">,</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">"expires_in"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">:</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;">7200</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;">}</SPAN>