Hi,
When using the getTransactionDetailsRequest there appears to be an unexpected character returning from the request which is causing issues trying to parse the JSON
Here is a javascript example which can re-create the problem if you fill in the 3 fields that I have removed.
var r = require('request-promise');
var f = {
"getTransactionDetailsRequest": {
"merchantAuthentication": {
"name": *NAME*",
"transactionKey": *TRANSACTION_KEY*
},
"transId": *TRANS_ID*
}
};
var options = {
url: 'https://apitest.authorize.net/xml/v1/request.api',
method: 'POST',
body: f,
json: true,
}
r(options)
.then(function(res) {
console.log(
'Mystery Character: Unicode', require('diff').diffChars(res, res.trim())[0].value.charCodeAt(0)
);
})The character that appears at the very start of the string is: http://www.fileformat.info/info/unicode/char/feff/index.htm
Do you consider this a bug?
Is this already tracked?
Thanks!
11-06-2017 08:58 AM
A byte order mark (BOM) consists of the character code U+FEFF at the beginning of a data stream, where it can be used as a signature defining the byte order and encoding form. In this case, the initial BOM is only used as a signature — an indication that an otherwise unmarked JSON response is in UTF-8. Although not necessary, it was determined that there was too high of a likelihood of breaking people's existing implementations in production, if the BOM stopped appearing.
In the next version of the API, there should not be a BOM in the wrong place.
In the mean time, if it is a problem for you, just be aware of it and parse it out.
11-07-2017 02:35 AM