Forum Discussion

WilliamHunter's avatar
WilliamHunter
Qrew Trainee
8 months ago

API call to put text in a multi-line text field

How via an external API call do I have to format data for a multi-line text entry field in Quickbase? I have properly obtained the JSON data but I cannot figure out how to properly format it to put it back in another multi-line text field. This is how the data looks, but it gives me an error each time I try to place it in the field. 

"Status: |incomplete\r\n\r\nTroubleshooting steps: |arrived onsite to troubleshoot the connection between a wall plate port and a pharmacy pc. port ph19 is not live. tried 2 patch cables neither worked. plugged pc into port ph 18 and the pc worked. i went back to the switch in the bathroom and traced thevcable from the patch panel to the switch fir ph19 and it was dead. tried a new patch cable, nothing. at this point the pharmacist told me that they were remodeling the pharmacy and there were guys running up in the ceiling and thay is when this problem started. im sure the cable was damaged in the ceiling and a new homerun cable needs ran from port ph19 to the switch inbthe bathroom of the pharmacy.\r\n\r\nMOD Name: |\r\n\r\nCheck-In: |5.00\r\n\r\nCheck Out: |6.15\r\n\r\nDelays on site: |\r"

The error I am getting makes it appear as if its a formating issue, and here is the error:

Failure on {"message":"Invalid Input","description":"Expected ',' or '}' after property value in JSON at position 336"}

and here is my API call:

                        CHANGE_URL="https://api.quickbase.com/v1/records"
 
                        # Construct the JSON data for the edit
                        status_data='{
                        "to": "bpq4irp4i",
                        "data": [
                                {
                                "3": {
                                        "value": "206722"
                                },
                                "52": {
                                        "value": "'"${escaped_notes_escaped}"'"
                                }
                                }
                        ]
                        }'
 
 
                        # Make the API call using cURL
                        HTTP_STATUS8=$(curl -s -X POST "${HEADERS[@]}" -d "${status_data}" -w "%{http_code}" -o new_response.txt "${CHANGE_URL}")
                        RESPONSE8=$(cat new_response.txt)
                        rm new_response.txt
                        if [[ ! ($HTTP_STATUS8 -ge 200 && $HTTP_STATUS8 -lt 300) ]]; then
                        echo "Failure on ${RESPONSE8}"
                        fi



------------------------------
William Hunter
------------------------------

5 Replies

  • Your payload just from a general setup looks wrong with how you're intermingling your ' and "". Since you're doing a curl and your json needs to be a string - I would expect it to look more like this: 

                            status_data='{
                            "to": "bpq4irp4i",
                            "data": [
                                    {
                                    "3": {
                                            "value": "206722"
                                    },
                                    "52": {
                                            "value": "' + escaped_notes_escaped + '"
                                    }
                                    }
                            ]
                            }'
    If you're trying to user the ${} syntax you need to make it a template string using ` instead of ' like so -
                            status_data=`{
                            "to": "bpq4irp4i",
                            "data": [
                                    {
                                    "3": {
                                            "value": "206722"
                                    },
                                    "52": {
                                            "value": "${escaped_notes_escaped}"
                                    }
                                    }
                            ]
                            }`
    You should still only have one " next to value but you should be using a grave accent ` instead of a single quote '


    ------------------------------
    Chayce Duncan
    ------------------------------
  • Also remember , your api call will essentially "overwrite" the value in this field not append to it. 

     @Chayce Duncan, what does ${} syntax do ?

    Prashant Maheshwari
    ------------------------------

    • ChayceDuncan's avatar
      ChayceDuncan
      Qrew Captain

      ${} is the syntax for using template literals - where you use `` to encapsulate the entire string without having to break or close out strings to do variables. So instead of: 

      var name = "Chayce";

      var string = "My name is " + name

      You can use `` to do: 

      var string = `My name is ${name}`



      ------------------------------
      Chayce Duncan
      ------------------------------
  • Hello, try with: {"count" : 1, "test" : "line1 \\n\\n Line2"}

    Thank you

    Marcelo Benavides Torres


    ------------------------------
    Marcelo Benavides
    ------------------------------
  • I got it figured out. Thanks all. 



    ------------------------------
    William Hunter
    ------------------------------