Help Rest api working with curl but giving hard time in c#

Hi we are trying to use DF for creating user accounts as follows

curl -X POST http://url/rest/system/user/ -H ‘X-DreamFactory-Application-Name: admin’ -H ‘X-DreamFactory-Session-Token: dfa1a625efa935c5dc780d4bf925db15’ -d ‘{ “display_name”:“Joe Smith”,“first_name”:“Joe”, “last_name”:“Smith”, “email”:"joe.smith@acme.com", “phone”:“555-666-7777”, “is_active”:true, “is_sys_admin”:false, “role_id”:2, “password”:“password” }’

it works perfectly same is the case when using POSTMAN web client

but when trying to use it in c# Dotnet 4.5
it is not working , i know technically it’s not Dream Factory rather c# shortcoming
can someone please help me out with this

thanks

ok i cracked it ,

using unirest.io as recommended by DF team

HttpResponse myClass = Unirest.post(“http://httpbin.org/post”)
.header(“accept”, “application/json”)
.body("{“parameter”:“value”, “foo”:“bar”}")
.asJson();

using above replacing with

and formating record structure which is {“record”:[{“0”:“bobthebuilder@norbiton@2”}]}
as @{"“record”":[{"“0"”:"“bobthebuilder@norbiton@2"”}]}

makes it works

thanks

1 Like

even cleaner:

string obj = “{ “email”: "somebloke@email.com”, “password”: “iforgot”, “duration”: 0 }";
var o = Newtonsoft.Json.JsonConvert.DeserializeObject< dynamic >(obj);

…then you can do:

.body(o).asJson();

Have you tried using the Nuget Package DreamFactory? You can pull it straight from Visual Studio. If you need help with usage, drop me a line