Errors in objectCreate: non-accepted key starting characters

Hello,
I am trying to use the objectCreate mutation of GraphQL to create a new object. When I am pushing a simple input (as the one in the example below), the function works perfectly.

mutation{
  objectCreate(    
    objectInput:{
      streamId: "XX"
      objects: [ { id: "XX", units: "mm"}]}
  )
}

When I try to push a more complicated input, I receive various error messages. Most of them are caused because of the first character of the input keys (i.e. when the keys start with characters such as @ or number), as depicted in the example below:

mutation{
  objectCreate(    
    objectInput:{
      streamId: "XX"
      objects: [ { id: "XX", units: "mm", 
        @Default:[{referencedId:"XX",speckle_type:"reference"}], 
        __closure:{0b00b000000bbb000bb00b00b0000000:"3" }}]}
  )
}

Is there something that I could do for the mutation to accept those characters? Otherwise is there another way to push a new object in the Speckle database (i.e. REST API call)?
Thank you in advance.

Hi Maria!
Sorry for the slow reply, yes, there’s another way to create objects. It consist in streaming the data directly to the Server, and I think it’s preferred over using the objectCreate mutation. You can find sample C# code in the Server Transport, I’m not very familiar with this part, but @dimitrie can clarify further if needed!

Hello @teocomi!
If you or @dimitrie, could provide an example of how to use that it would be great!

Morning! I think it’s because things are not properly serialised json. You might get away in simple scenarios, but in more complex ones things fail.

We usually pass this in as “variables” next to the query, rather than in the query itself.

The mutation:

mutation($input:ObjectCreateInput!){
  objectCreate(objectInput:$input)
}

The variables:

{
 "input": {
  	"streamId": "92b620fb17",
  	"objects": [ 
      { "@test": "it works!", "applicationId":"first", "numVal":560.23 }, 
      { "42" : "meaning of life", "applicationId":"second",  "boolVal":false}
    ]
	}
}

PS: Mind you, the any key in the closure dictionary should (eventually) become an object, otherwise you will be creating invalid data (it’s all part of the decomposition api…)