locked
Access a Rest Service online

    Question

  • Hi,

    Rest services exist since years. But now that I want to do a simple thing in a few lines, like with the RestSharp Nuget package (http://restsharp.org/). It seems very very very complicated.

    1) If I try to install restsharp, it won't accept :

    Could not install package 'RestSharp 104.4.0'. You are trying to install this package into a project that targets '.NETCore,Version=v4.5.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."

    2) If I try to install restsharp.portable, I get this error and can't compile : Error 1 Cannot find type System.ApplicationException in module mscorlib.dll. 

    3) If I look on the web, I can find :

    - outdated examples, It seems that everytime they change the guy at the head of dev department @Microsoft it seems he thinks that everything was rubish and they start to trash everything and built all over again

    - examples that are way too complicated... If I'm doing .NET I want easy things. If I would want something complicated then I would choose Objective C...

    4) I have to sign my request, using :

    Dimhmac = NewHMACSHA256(Encoding.UTF8.GetBytes(Me.Token))

           

    Dimsha256 = NewSHA256Managed


           

    Dimsig = Convert.ToBase64String(hmac.ComputeHash(sha256.ComputeHash(data)))

    Now that everything is different with how Windows Store App, how can I do that ?

    Thanks you guys for helping me out


    Steve

    Saturday, August 9, 2014 9:20 AM

Answers

  • Hi Stivo,

    A really simply question, does RestSharp support Windows Store App? I did not see the documentation on github mentioned it support Windows Store App, but I do see someone extend it for Windows Store App in the github discussion post: https://github.com/restsharp/RestSharp/issues/333

    And for your another question, how to send parameters by post, I would say you can try something like I show you below:

    Dictionary<string, string> dic = new Dictionary<string, string>();
    dic.Add("p1", "v1");
    dic.Add("p2","v2");
    
    HttpMultipartFormDataContent form = new HttpMultipartFormDataContent();
    foreach (var parm in dic)
    {
         form.Add(new HttpStringContent(dic.Value), dic.Key);
    }
    
    try
    {
        HttpClient httpClient = new HttpClient();
        HttpResponseMessage response = await httpClient.PostAsync(new Uri(uri), form);
        return await response.Content.ReadAsStringAsync();
    }
    catch (Exception ex)
    {
                    
    }

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 11, 2014 7:26 AM
    Moderator

All replies

  • correction concerning point 2:

    Error 1 Cannot find type System.ApplicationException in module mscorlib.dll

    I get this error. When I install BCrypt.Net. I try now to use CryptSharp...


    Steve

    Saturday, August 9, 2014 9:46 AM
  • this link is a simple exemple :

    http://blogs.msdn.com/b/wsdevsol/archive/2014/01/09/consuming-rest-services-in-your-windows-store-and-phone-applications.aspx

    but does not show how to send parameters by post


    Steve

    Saturday, August 9, 2014 9:56 AM
  • Hi Stivo,

    A really simply question, does RestSharp support Windows Store App? I did not see the documentation on github mentioned it support Windows Store App, but I do see someone extend it for Windows Store App in the github discussion post: https://github.com/restsharp/RestSharp/issues/333

    And for your another question, how to send parameters by post, I would say you can try something like I show you below:

    Dictionary<string, string> dic = new Dictionary<string, string>();
    dic.Add("p1", "v1");
    dic.Add("p2","v2");
    
    HttpMultipartFormDataContent form = new HttpMultipartFormDataContent();
    foreach (var parm in dic)
    {
         form.Add(new HttpStringContent(dic.Value), dic.Key);
    }
    
    try
    {
        HttpClient httpClient = new HttpClient();
        HttpResponseMessage response = await httpClient.PostAsync(new Uri(uri), form);
        return await response.Content.ReadAsStringAsync();
    }
    catch (Exception ex)
    {
                    
    }

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 11, 2014 7:26 AM
    Moderator