<\/HEAD>
Ich versuche, ein Token für ArcGIS Online mit c# (genauer gesagt SSIS) zu erhalten. Ich habe eine URL, die ich verwenden kann und die gut funktioniert, und ich kann sie in Chrome aufrufen und bekomme, was ich brauche, aber es funktioniert nicht über c# mit einem WebClient.<\/SPAN><\/P><\/P>Ich kann andere JSONs über SSIS\/C# WebClient abrufen, aber aus irgendeinem Grund NICHT ArcGIS Online. Die URL funktioniert in Chrome, liefert aber keine Antwort über SSIS\/C# WebClient.<\/P>Mein Code (mit client id\/secret\/credentials) ist:<\/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: 0px; font-weight: inherit; font-size: 13px;"><\/SPAN><SPAN class="" style="color:#101094;border:none;font-weight:bold;font-size=13px">string<\/SPAN> json <SPAN style='border:none;font-weight:bold;font-size=13px'>=<\/SPAN> wc.<SPAN style='border:none;font-weight:bold;font-size=13px'>DownloadString<\/SPAN>(webResource);\n<\/CODE><\/PRE><P style="color:#242729;background-color:#f9f8f6;border:none;margin-bottom:.5em">Ich würde dann das JSON parsen.<\/P><P style="color:#242729;background-color:#f9f8f6;border:none;margin-bottom:.5em">Momentan erhalte ich:<\/P><BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"><P><CODE>DTS <SPAN style='color:#2b91af'>Script<\/SPAN> <SPAN>Task</SPAN> hat eine Ausnahme im Benutzercode ausgelöst:<BR>Projektname:<BR>ST_0a306cf2e1634509bea49b75b7d93265 <SPAN style='color:#2b91af'>Exception<\/SPAN> wurde von dem Ziel einer Aufrufaktion ausgelöst.<BR>bei <span style='color:#2b91af'>System<\/span>.<span>RuntimeMethodHandle.InvokeMethod</span>(Object target, Object[] arguments, Signature sig, Boolean constructor)<BR>bei <span style='color:#2b91af'>System<\/span>.<span>Reflection.RuntimeMethodInfo.UnsafeInvokeInternal</span>(Object obj, Object[] parameters, Object[])
#303336; border: 0px; font-weight: inherit; font-size: 13px;"> Argumente
) bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) bei System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags,
Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) bei Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()Ich habe eine Anwendung erstellt, wie beschrieben in https://developers.arcgis.com/labs/rest/get-an-access-token/
Ein Beispiel des zurückgegebenen JSON (über Chrome) ist:
{<span> 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>