Skip to main content

Hi everyone! How is it going?

I’m wondering if anyone could help with a problem that I have been facing.

I’m trying to create a card on one of my pipes using .NET but I keep getting BadRequest every time. But the strange thing is that I’m using the same query on a REST client and it works every time.

 

Could someone please help me with this?

 

 

var jsonString = "{ \"query\": \"mutation{createCard(input:{pipe_id:302295485 title:\"title\" fields_attributes:t{field_id:\"texto_form\", field_value:\"valor_form\"}]}){ card{id title}}}}";
 

 

 

Hi @wesbalbino,

I have a question about your session. Do you log in when you try to POST in our API?

The REST client is working because you are authenticated in another browser’s tab.


Hi @wesbalbino,

I have a question about your session. Do you log in when you try to POST in our API?

The REST client is working because you are authenticated in another browser’s tab.

Hi Naoki, I have excactly the same problem.

It works great in Postman, but not in C#.

It is NOT a session problem because if I replace the query that works in Postman with

            string query = "{\"query\": \"{ me { id email } }\"}";

it works fine.

 

Our entire sales pipeline with hubspot CRM integration project is stalled because of this bug and we would love some help.

 

I would be happy to provide an example C# project for you to study and reproduce the issue.

 

 


Also, there are no more details provided from the API what could be the problem. It just says “Bad request”. It does appear that it is the “field_id” that is the problem, (string vs ID! type (what ever that is in a json string???))  but I’m not sure.


Hey everyone! My problem was actually being caused by the .NET lib that I was using (RestSharp). I had the idea to use another lib (GraphQL.Client and GraphQL.Client.Serializer.Newtownsoft) and everything worked as expected.

Hope this helps you @jakob-nystrom  :)


Hey everyone! My problem was actually being caused by the .NET lib that I was using (RestSharp). I had the idea to use another lib (GraphQL.Client and GraphQL.Client.Serializer.Newtownsoft) and everything worked as expected.

Hope this helps you @jakob-nystrom  :)

I actually switched from RestSharp because I had problems getting the graphQL Client to work, I ended up with serialization errors and bla bla.

Could you be so kind and post a working code snippet with a mutation database table query like the one in your first post? I would really appreciate that!!

That said, RestSharp SHOULD work but yeah if I can get it to work with the GraphQL Client Library that would be even better


 Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

 

This error above was indeed beacuse of a session error, when switching back to GraphQLClient I had omitted the authorization header: 

 

graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {Configuration.GetValue<string>("PipefyApiToken")}" );

 

I am getting something back, let’s see if I can get the data I actually want now


Hey everyone! My problem was actually being caused by the .NET lib that I was using (RestSharp). I had the idea to use another lib (GraphQL.Client and GraphQL.Client.Serializer.Newtownsoft) and everything worked as expected.

Hope this helps you @jakob-nystrom  :)

 

So, this is what I am getting. Given that the querystring is a STRING, why on earth does the Pipefy API complain that it wants an ID! type?!?!?!

This STRING works great in Postman for me. Not using Restsharp, not using GraphQLClient.

 

			var fieldId = "text";
var fieldValue = "test2000";
var meRequest = new GraphQLRequest {
Query = "mutation { createTableRecord(input: { table_id: 302428234, fields_attributes: { field_id: " + fieldId + ", field_value: " + fieldValue + " } }) { table_record { id }}}"
};
try {
var me = await graphQLClient.SendQueryAsync<TableRecordResponseType>(meRequest);
Log.Debug(JsonConvert.SerializeObject(me, Formatting.Indented));
}
catch (Exception ex) {
Log.Debug(ex.Message);
if (ex.InnerException != null) { Log.Debug(ex.InnerException.Message); }
}
 "statusCode": 200,
"data": null,
"errors": r
{
"locations": t
{
"column": 79,
"line": 1
}
],
"message": "Argument 'field_id' on InputObject 'FieldValueInput' has an invalid value (text). Expected type 'ID!'.",
"path": "
"mutation",
"createTableRecord",
"input",
"fields_attributes",
0,
"field_id"
],
"extensions": {
"code": "argumentLiteralsIncompatible",
"typeName": "InputObject",
"argumentName": "field_id"
}
},
{
"locations": t
{
"column": 79,
"line": 1
}
],
"message": "Argument 'field_value' on InputObject 'FieldValueInput' has an invalid value (test2000). Expected type 'dUndefinedInput]'.",
"path": "
"mutation",
"createTableRecord",
"input",
"fields_attributes",
0,
"field_value"
],
"extensions": {
"code": "argumentLiteralsIncompatible",
"typeName": "InputObject",
"argumentName": "field_value"
}
}
],

 


OK so right now I have boiled down the issue to this:

 

This WORKS, it creates an entry in the database:

 

var meRequest = new GraphQLRequest {
Query = "mutation { createTableRecord(input: { table_id: 302428234, fields_attributes: { field_id: \"text\" field_value: \"test2000\" } }) { table_record { id }}}"

};

 

This does NOT work, it gives the errors outlined in previous reply, expecting ID! type and UndefinedInput type. The difference is I am using variables in the string.

var fieldId = "text";
var fieldValue = "test2000";
var meRequest = new GraphQLRequest {
Query = "mutation { createTableRecord(input: { table_id: 302428234, fields_attributes: { field_id: " + fieldId + ", field_value: " + fieldValue + " } }) { table_record { id }}}"
};

This also does NOT work, ( { are escaped by using double {{ and  }} respectively)

var fieldId = "text";
var fieldValue = "test2000";
var meRequest = new GraphQLRequest {
Query = $"mutation {{ createTableRecord(input: {{ table_id: 302428234, fields_attributes: {{ field_id: {fieldId} field_value: {fieldValue} }} }}) {{ table_record {{ id }}}}}}"
};

 

Of course, using variables is an absolute must.

@pipefy_api  Why would the API accept hardcoded strings but not string variables in a string query? 


Hey Jakob! :)

I’ll take a look at your code and I’ll get back to you


Hey Jakob! :)

I’ll take a look at your code and I’ll get back to you

 

Hey, appreciate it, but this turned out as well to be a GBTW issue (Garbage Behind The Wheels)

When changing to variables. I did not keep the escaped quotes \”

 

var meRequest = new GraphQLRequest {
Query = $"mutation {{ createTableRecord(input: {{ table_id: 302428234, fields_attributes: {{ field_id: \"{fieldId}\" field_value: \"{fieldValue}\" }} }}) {{ table_record {{ id }}}}}}"
};

 This actually works =)

Hope this helps someone else

 


Hey man!

 

The issue is that you need to escape the quotes around the fieldId valur and around the fieldValue.

 

"mutation { createTableRecord(input:  { table_id: 302428234, fields_attributes: { field_id: \"" + fieldId + "\" field_value: \"" + fieldValue + "\" }}) { table_record { id }}}";

 

Try this query 


Hey man!

 

Thanks for taking a look. Yes I just realized it, 1 minute before you posted, look above 🙂 🙂 =) 


Hey man!

 

Thanks for taking a look. Yes I just realized it, 1 minute before you posted, look above 🙂 🙂 =) 

No problem! I’m glad everything worked out as expected :)

 

 


Reply