Skip to main content

I'm trying to send a long string over the API. However, I cannot find out how to properly format/encode the string in order for Pipefy to simply add the text to the database record.

Here's how I'm building the query:

return `mutation {
createTableRecord(input: {
table_id: "**",
fields_attributes: [
{field_id: "what", field_value: "${data.firstName}"},
{field_id: "nom", field_value: "${data.lastName}"},
{field_id: "email", field_value: "${data.Email}"},
{field_id: "cellulaire", field_value: "${data.Phone}"},
{field_id: "site_web", field_value: "${data.formRef}"},
{field_id: "message_soumis", field_value: "${data.Message}"},Here, data.Message has a long text in which there are newlines. This breaks it all:400 - {"errors":[{"locations":[{"column":51,"line":10}],"message":"token recognition error at: '\"Monsieur,\n'"}

 

There are tens of such lines. How should I format/encode the text so it is added and properly formatted in the Pipefy DB record?

Hey Thiago, 

 

It seems you’re facing some problems with unescaped char.

 

With strings you need to insert backslashes to escape special chars. If you’re declaring this information in a variable, this escaping must be applied in the variable content. 

 

Here and example in Ruby where the string is declared in a var. 

 

require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.pipefy.com/graphql")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
requestr"authorization"] = 'Bearer YOUR_TOKEN'
requestr"content-type"] = 'application/json'

text = "\\\"Buck did not read the newspapers, or he would have known that trouble was brewing, not alone for himself, but for every tide-water dog, strong of muscle and with warm, long hair, from Puget Sound to San Diego.\\\""

request.body = "{\"query\":\"mutation{ createCard( input: { pipe_id: 301315432 fields_attributes: t {field_id: \\\"text\\\", field_value: #{text}} ] } ) { card { id title } } }\"}"

response = http.request(request)
puts response.read_body

 

Our Developers page has a Code Console where you can insert your query or mutation and check the type escaping must be applied in your code. 

 

 


Reply