GPT Action refuses to urlencode question mark

I created an action to make calls to this REST API:

/my path/{sessionid}/{model}/{max_tokens}/{question}/{groups}/{tags}/{source}/{email}/{configId}/{userEmail}:

The “question” field is taken directly from the GPT prompt. This mostly works, except if the question ends with a question mark. Then it fails.

What needs to happen is the question needs to be urlencoded. But, so far in instructions I have not been able to get the GPT to do that. I finally had to give it instructions to simply remove the question mark. I needed these two sets of sentences to finally get it to do that:

Please always remove the question mark ? from the question text.

You will need to urlencode the question field. Do NOT urelencode the path slashes “/”. These are required by the server to be able to separate the fields received. You must urlencode the entire text of the question, including the question mark.

Now, unless I’m missing something, telling it to urlencode a field that includes a question mark should be enough. Then telling it to urlencode the question mark itself should really do it. I think having to tell it to remove the question mark is a bit much.

I can see this being a challenge to overcome.

The AI is the one emitting the language. A URL can’t be post-processed to know if mid-url there is a misplaced character or a separator for a query string.

You can try prompting: URLs sent to xxx must have all question marks to be transmitted to the recipient replaced with %3F which is proper URL encoding. Replace “?” with output of a “%3F”.

1 Like