Hello everyone,
I have an error while trying to make an API call, I get an error for unresolved DNS.
The API is for sending SMS messages, I have 2 usecases when which I use this API, first is individual messaging and that sometimes gives this error, but usually after 2 or 3 times (of error) it succeeds.
The second usecase is when i use Beckend workflow and i schedule an API call (recursive) that will create a few messages each iterate, but every time at the first iterate it gives me an error and shuts down the workflow.
I’ll add some screenshots for the error that i get. (the API itself is pretty simple and should not have mistakes because it works in the first usecase eventualy)
Any Advice?
Can you share api connector settings?
Thanks for replying
I’ll add the api connector settings but i changed some of the values because they are private keys for the API
(All values are hard coded except recipent and msg)
It may be the msg that could contain unescaped characters. You could remove doubles quotes around <msg>
and use :format as json-safe. However the error message seem more related to url fetching like if the domain was not accessible at this moment. Do you have link to api doc?
Oh also you forget all the doubles quotes around the leys!
Just in case, ensure that all letters in the url are Latin, not Cyrillic. Most often its letter C that is mistyped.
Oh, around {number} and {msg} your’e right!
API docs link:
https://www.sms4free.co.il/outcome-sms-api.html
I’m not sure if you can see the docs without logging in… if not tell me ill send the required information
and about the json-safe ill try it
Thankss!
Edit: after checking the double quotes are necessary…
Oh, that can be the problem becuase I do save some url params in another languages, english (should be fine) russian and hebrew…
If i wont use russian and hebrew in the url it should not do the error?
because the DNS error pops also when I initialize the API call (no url russian or hebrew params)
only msg variable gets hebrew and russian messages to send… (text)
tell me if its ok to leave it like that or it should be addressed.
Thank you!
You can use any language in url params generally, there shouldn’t be any problem with that, though in a perfect world they should be encoded.
But in the screen above you dont use URL parameters, these are parameters substituted in the request body. The only reason you have Unresolved DNS problem is that you might occasionally types Cyrillic C in https://api.sms4free.co.uk/… URL or there might be other letters similar to Latin, but mistyped in different encodings because they look exactly the same as Latin ones.
DNS resolves the host (if its typed correctly) just fine, I’ve just tested.
Hey Thanks again for the detailed explanation,
I’m trying to understand everything… but as i see it you are talking about the URL in the API call and that URL never changes… so no Cyrillic letters can be typed there.
The call (and DNS) works fine sometimes, but sometimes it does not, and with beckend workflows it doesnt work at all (same URL for API)(screenshots for beckend workflows at the top of the topic)
could you explain what things i should try doing to fix it? like where to make sure nothing Cyrillic is typed? (API URL is static)
Thank you!!!
I have a suspicion that it is the {msg} variable im sending, I’m not exactly sure but when i tested the api with just “hey” it didnt make any errors but now almost every SMS is in hebrew or russian so maybe thats the cause?
I’ll look into it in the meantime
Edit: Nevermind the msg’s text is not the problem
The message text is in the body, it does not affect URL address at all.
DNS resolution is performed on the origin of the URL, i.e. a part between https:// and the first path separator after it, which is literally api.sms4free.co.il
.
If the issue is not 100% reproducible, that means some problems with DNS, there’s not much you can do, but…
Lets start from the button up:
a DNS record for api.sms4free.co.il
is a CNAME for sms4free-api.purplesea-7883c4a2.westeurope.azurecontainerapps.io
which resolves to IPv4 address of 20.73.238.245
What I suggest:
- try to use IP address instead of
api.sms4free.co.il
(substitute hostname with IP in the URL) and test it. If it works fine, then it looks like a DNS problem. If it fails at least sometimes, i.e. you still see DNS resolution failures, then DNS has nothing to do with that problem in fact - that might be incorrect error message or something else - let’s first check if you need to dive further in this direction. - if 1 step works fine, try to use
sms4free-api.purplesea-7883c4a2.westeurope.azurecontainerapps.io
as a hostname in the URL. Pay attention to the result. - get back to the original URL and try it again to complete excerise. If option 2 works fine and option 3 fails sometimes, then that’s a DNS problem, but I cannot tell what could be the cause at the moment, you probably would need to google it.
In any case, this would give a lot to think about and other smarter guys might help then having this information at hand.
Edit:
Sorry, just noticed: IPv4 will probably fail - the IP above belongs the Azure Cloud, which will probably not handle requests sent to IP URLs… But you can try option 2 and 3 just to see the result.
Awsome answer I’ll be sure to give those options a try to understand more.
Moreover I found a hint that may be helpfull:
I tried to play around with the msg input im sending in API call,
First I found that when i’m not using a bubble variable (Dynamic value), it does not give me the DNS error and the API works really great.
So now im starting to think that this is the root of the problem.
I’ll illustrate with screenshots:
this is not working (original dynamic value that i need to use for different dynamic messages)
this is working perfectly:
I tried a few different dynamic values, it happens with all of them.
now we need to figure out how to insert those dynamic values(all of them are data from step 1) and not trigger the error
You need to use :formatted as JSON-safe
to generate correct string.
For example:
You message have line breaks that makes you body invalid. Just imaging you substituted the message into the body:
{
msg: "Hello, Angela!
We start tomorrow 2024, 17 ...
At "10:00"
In Sheba hotel"
}
If you make it JSON-safe, the string will evaluate to "Hello, Angela!\nWe start tomorrow 2025, 17 ...\nAt \"10:00\"\nIn Sheba hotel\"
and this will be a valid string value. The only thing is that you need to remove quotes around <msg>
, because :formatted as JSON-safe
will add its own quotes, so your body should look like
{
...
msg: <msg>
...
}
You just need to always do :formatted as JSON-safe
each time you put dynamic value into the corresponding field.
Great !
Now I can’t try it but when i get home I’ll be sure to try.
Hope this will put an end for all the errors
Thank you so much !!
Learned alot with you today, I’ll follow up as soon as I try.
Tnx I managed to make it work!!!
Much appreciated!