Trying to send text message using sp_send_dbmail truncates url in body - sql

I'm using send_dbmail to send a text message to customers. This is the following sql:
exec msdb.dbo.sp_send_dbmail
#recipients='5558881234#txt.att.net',
#body='check out this url https://www.someurl.com/directory/blah.aspx',
#subject='I am the subject!'
The body gets truncated to "check out this url https://www.someurl.com/directory/blah.as" (the "px" is removed from the end of the url).
I've ruled out message length as I have tried sending just "www.google.com/test.aspx" and the "px" is removed as well. Another strange thing, when I try forwarding the text message to myself and add the "px" back on myself, it works. It also works if I send a email from outlook with the same body.
Any ideas?
Thanks.

Seems strange. Have you tried passing unicode strings, i.e. N'check out this url ....', or silly suggestion, have you tried padding the end of your string with a few whitespace characters, or perhaps a few whitespace characters followed by a period? What happens if the body text doesn't end in .aspx, but ends in anything else such as "this is a test", etc.?

Related

How to escape out a backslash in API Request

I'm trying to hit the stock item WSE ("~entity/Default/20.200.001/StockItem/{keyvalue}") but when I have a InventoryCD with a slash in it (eg: "WD-ON/OFF") and I run it, I get the error Operation is not valid due to the current state of the object.
I tried using WebUtility.UrlEncode("WD-ON/OFF") to replace the / with %2f, but that doesn't seem to do anything. Per a long shot on the Aug forums, also tried to use "//" but that also does nothing.
The exact same code with a non-slash item works just fine.
Thoughts?
You should HTML encode your string
string myEncodedString = HttpUtility.HtmlEncode(filename);
It turns out that I'm not doing anything wrong. Acumatica support has sent this to Engineering, and there will be some future fix. For now, "don't do that" is their answer.

SES sends base64 characters in email body (instead of html) [ basic case]

I am having issue with html sent vis aws-ses. Every once in a while it sends base64 text in email body. I was able to capture a html that has this problem and could not figure out the issue - hoping if any one else has any idea on how to fix it.
I even created a test case to reproduce this issue.
Test case link: https://drive.google.com/file/d/1LWrnQowI4yLr1nYOSzcCF7_gH1sJ9_ht/view?usp=sharing
I am using java sdk to send email via SES and transmitting HTML to ses server but it sends base64 characters in email body as shown below:
=?UTF-8?B?PCEtLVtpZiBndGUgbXNvIDldPjx4bWw+CiAgICAgPG86T2Zm?= =?UTF-8?B?aWNlRG9jdW1lbnRTZXR0aW5ncz4KICAgICAgPG86QWxsb3dQTg==?= =?UTF-8?B?Ry8+CiAgICAgIDxvOlBpeGVsc1BlckluY2g+OTY8L286UGl4?= =?UTF-8?B?ZWxzUGVySW5jaD4KICAgICA8L286T2ZmaWNlRG9jdW1lbnRTZQ==?= =?UTF-8?B?dHRpbmdzPgogICAgPC94bWw+PCFbZW5kaWZdLS0+CjxodG1s?= =?UTF-8?B?PgogPGhlYWQ+IAogIDxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbg==?= =?UTF-8?B?dC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9?= =?UTF-8?B?dXRmLTgiIC8+IAogIDxtZXRhIG5hbWU9InZpZXdwb3J0IiBjbw==?= =?UTF-8?B?bnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCIgLz4gCiAgPCEt?= =?UTF-8?B?LVtpZiAhbXNvXT48IS0tPiAKICA8bWV0YSBodHRwLWVxdWl2PQ==?= =?UTF-8?B?IlgtVUEtQ29tcGF0aWJsZSIgY29udGVudD0iSUU9ZWRnZSIg?= =?UTF-8?B?Lz4gCiAgPCEtLTwhW2VuZGlmXS0tPiAKICA8dGl0bGU+PC90aQ==?= =?UTF-8?B?dGxlPiAKICA8c3R5bGUgaWQ9Im1lZGlhLXF1ZXJ5IiB0eXBl?= =?UTF-8?B?PSJ0ZXh0L2NzcyI+Ym9keSB7CiAgbWFyZ2luOiAwOwogIHBhZA==?= =?UTF-8?B?ZGluZzogMDsgfQoKdGFibGUsIHRyLCB0ZCB7CiAgdmVydGljYQ==?= =?UTF-8?B?

How to properly encode special characters in a REST API url

EDIT: The NHTSA docs, as CBroe points out, say to replace an ampersand with an underscore. However, I'm also getting an error with forward slashes (albeit a different one, page not found, because it's decoding the slash), for example the make 'EXISS/SOONER':
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/EXISS%2FSOONER?format=json
And replacing the ampersand with an underscore no longer results in an error message, but in zero results returned, which should not be the case.
ORIGINAL POST:
I'm trying to download the content from the following URL:
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/s&s?format=json
And the site returns the following error message:
Server Error in '/' Application.
A potentially dangerous Request.Path value was detected from the client (&).
The problem is the ampersand; a similar request for a different car make works:
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/toyota?format=json
I have verified from a different endpoint that S&S is a valid make for the API.
Based on stackoverflow answers, I've tried all the following without success:
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/s%26s?format=json
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/s%26amp;s?format=json
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/s%26amp%3Bs?format=json

Hash character in WCF REST parameter

I have a WCF service that accepts GET calls.
I have a dropdown on my ui that has a list of road exits (exit #1, exit #2, etc.)
When the user selects an exit and mashes a button i call that service with the selected value.
It gets encoded and i can see in fiddler that the end of the url looks like this:
EXIT%20%231
which corresponds to a user selection of EXIT #1
When this param gets to the server, however, all i see in it is the term EXIT.
I think this is related to the hash character having a special meaning in WCF.
Changing that hash tag in my records is not an option. Is there another option to get this to work?
If you have text that is being messed with in transit, you could try base64 encoding before you send it, then decode on the server side.

NSURLErrorDomain Code=-1000 "bad URL": What does it really mean?

I have this confusing error. I am sending JSON through GET method and a website will parse and display the data. The problem is I am getting the error "NSURLErrorDomain Code -1000" or more simply "Bad URL". The thing is when I check the server, the data I sent is successfully parsed and displayed. So I am really confused why am I getting this "bad URL" error at all. Can anyone helped me out?
Here is the error I am receiving:
Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0xff73df0 {NSUnderlyingError=0xff73810 "bad URL", NSLocalizedDescription=bad URL}
EDIT:
http://sample.com/imwebjson.php?sid=5amp13&job=sendNotes&im_flds={\"im_uid\":"1",\"im_bookid\":"57",\"im_pagenr\":"1",\"im_notes\":"Testing%5C%5Cn"}
Ok you might ask why some parts of the JSON string is encoded already. These encoded parts are special characters. I realized that the stringByAddingPercentEscapesUsingEncoding is very incomplete. It doesn't encode all special characters, and what more is that when it encodes some special characters, the URL is not recognized at all. So I decided to manually encode the special characters into the string.
The colon character : (at least, possibly others like " and {) needs to be percent encoded in URLs.
In the GET parameters you have to change spaces " " for "%20"