json - Call API using Refit and deserialize to dynamic -


i'm calling rest service using refit , want deserialize json returned dynamic type.

i tried defining interface

[get("/foo")] task<dynamic> getfoo(); 

but call times out.

i know can deserialize dynamic this

var mockstring = "{ title: { name: 'fred', book: 'job'} }"; dynamic d = jsonconvert.deserializeobject(mockstring); 

but can't figure out pass refit same.

another option refit pass raw json can deserialize myself can't see way either.

any ideas?

refit uses json.net under hood, deserialization works work refit, including dynamic. interface have described right.

here's real working example:

public interface ihttpbinapi {     [get("/ip")]     task<dynamic> getip(); }  var value = await restservice.for<ihttpbinapi>("http://httpbin.org").getip(); 

if using ios , refit 4+, might seeing bug: https://github.com/paulcbetts/refit/issues/359

as steven thewissen has stated, can use task<string> return type (or task<httpresponsemessage>, or task<httpcontent>) receive raw response , deserialize yourself, shouldn't have -- whole point of refit it's supposed save hassle.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -