Hello,
i am trying to use OrientDB HTTP interface to work with it from GoLang. but 
i have faced a problem in posting documents to database.
i have written following code:
func main(){

fmt.Println("starting")
answ := putDoc("http://localhost:2480/document/tt";, 
`{"name":"foo","age":20}`)
fmt.Println("answer is", answ)


}

func putDoc(url,cont string) string{
client := &http.Client{}
req, err := http.NewRequest("POST", url, bytes.NewBufferString(cont))
req.SetBasicAuth("root", "admin123")
req.Header.Set("Content-Type","application/json");

resp, err := client.Do(req);
if err != nil{
panic(err)
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)

return string(body)
}

but it gives this error:

com.orientechnologies.orient.core.exception.OSerializationException: Error 
on un
marshalling JSON content: content is null

i tried to set Content-Type to text/plain and also to work with structs and 
Marshall it into post data but still the same problem.
then I tried it in nodejs and used following code:

var Client = require('node-rest-client').Client;
var options_auth={user:"root",password:"admin123"};
client = new Client(options_auth);
cont = {
name: "foo",
age: 25
}
client.post("http://localhost:2480/document/tt";, cont, 
function(data,response) {
    console.log(data);
});

and the same problem. 
strangley enough this curl command work perfectly:
curl -POST -u root:admin123 -d "{'name':'foo', 'age':10}"

another option i tried was to use url-encoded-form-data with url.values in 
golang but the same problem .....

is it really broken? or where I am doing something wrong?
thanks in advance

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to