Hello,

I’ve run into what will hopefully be my final issue in this little project, again I’ve searched quite hard to find the answer but have come up short.

I’m having problems posting a message which contains a ’ character, because of the way such a string gets inserted into the cURL request.

 'Content-type: application/json' -d '{"text": "Today's (28th November)...

So the ’ character in the message ends the .json structure earlier than it should… so how can I escape this character in a message? I’ve tried the usual things like backslash, or percent encoding it, but it either doesn’t work still, or just sends the percent encode character as plain text in the tweet.

Also - is it possible to add carriage returns into a tweet, like with the web app? If so, what’s the code for that?

Thanks for your time and help.

It might work with a double escape? Like \\' and for newlines it’s \n so in your command try \\n

Or maybe:

-d $'{"text": "Today\'s \n(28th November)..."}'

The dollar sign before the '

From http - How to send line break with curl? - Stack Overflow

1 Like

Thanks Igor…

So " \\n " does indeed work for a carriage return. Unfortunately it doesn’t seem to work for ', and the trick with the dollar sign also falls down with the ’ character (it reads that as the end of the string).

From that Stack Overflow thread

  • This worked for me too. I’ll have to play around with it, because it didn’t work with double-quotes, which means that I can’t use single-quotes within the string.

Tyler Collier

Jul 14 '11 at 22:13

Half way there! Any other ideas? Thanks so much.

1 Like

As a workaround, maybe try a different type of single quote? Like

fish ’n’ chips

Vs

fish 'n' chips

Or

fish `n` chips
1 Like

Thanks Igor,

I had an epiphany this morning and crafted a search question like you did but for ’ rather than line break. And instantly the link I found pointed to

'\''

being the correct format, which does indeed work.

Your time and help is much appreciated!

Here’s a link to the kind of tweet I’ve been able to automate with the help of people on here! (without the ’ fix just yet).

Many thanks.

1 Like