I am Trying to call External URL From Suitelet its throwing 406 Error.
var user_name = ‘username’;
var password = ‘password’;
var url=”Url”;
var auth = nlapiEncrypt(user_name+’:’+password,’base64′);
var headers = new Array();
headers[“Content-Type”] = “application/json”;
headers[“Authorization”] = ‘Basic ‘+auth+”;
headers[“Token”] = ‘abcdddd-djfjjff-djd/dkdkd’;
var token_res=nlapiRequestURL(url, null,headers);
var token_response_XML = token_res.getBody();
nlapiLogExecution(‘DEBUG’, ‘token_response_XML’, token_response_XML);
Anyone Suggest Please?
Thanks in Advance
Based on a quick Google search (it's been a LONG time since I've seen that error code), it looks like your other system is not returning the data in the manner that is expected. I would suggest testing with something like the chrome ARC (Advanced REST Client) extension so that you can see the entire process and get it all perfected. Here is the page I read up on 406 errors to refresh my memory.
406 Not Acceptable
Related
I am trying to configure Mirth Connect Server 3.10.1 (Java version: 1.8.0_181), to write FHIR JSON docs to MongoDB. I've followed instructions from this post and have these drivers in custom-lib/
bson-4.2.0.jar
mongodb-driver-3.9.1.jar
mongodb-driver-core-4.2.0.jar
My conf/dbdrivers.xml has an entry like this,
<driver class"org.mongodb.Driver" name="MongoDB" template="mongodb://localhost:27017/" selectLimit="" />
I've setup my Channel Destination with a JavaScript Writer Connector Type and used this JS,
var mongoClient = new Packages.com.mongodb.MongoClient("localhost", 27017);
var database = mongoClient.getDatabase("synthea");
var collection = database.getCollection("synthea");
var jsonDoc = JSON.stringify(connectorMessage.getEncodedData(msg));
var doc = Packages.org.bson.Document.parse(jsonDoc);
collection.insertOne(doc);
var myDoc = collection.find().first();
logger.debug(myDoc.toJson());
mongoClient.close();
return;
When I deploy the Channel, I am getting this error.
Can anyone tell me what this means?
Any help or guidance very much (and humbly) appreciated.
JavaScript Writer error
ERROR MESSAGE: Error evaluating JavaScript Writer
java.lang.NoSuchMethodError: 'com.mongodb.connection.ConnectionPoolSettings$Builder com.mongodb.connection.ConnectionPoolSettings$Builder.maxWaitQueueSize(int)'
at com.mongodb.MongoClientOptions.<init>(MongoClientOptions.java:149)
at com.mongodb.MongoClientOptions.<init>(MongoClientOptions.java:57)
at com.mongodb.MongoClientOptions$Builder.build(MongoClientOptions.java:1612)
at com.mongodb.MongoClient.<init>(MongoClient.java:155)
at com.mongodb.MongoClient.<init>(MongoClient.java:145)
at jdk.internal.reflect.GeneratedConstructorAccessor135.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:171)
at org.mozilla.javascript.NativeJavaClass.constructInternal(NativeJavaClass.java:268)
at org.mozilla.javascript.NativeJavaClass.constructSpecific(NativeJavaClass.java:207)
at org.mozilla.javascript.NativeJavaClass.construct(NativeJavaClass.java:169)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1713)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1009)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:412)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3545)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:121)
at com.mirth.connect.server.util.javascript.JavaScriptTask.executeScript(JavaScriptTask.java:150)
at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:230)
at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:190)
at com.mirth.connect.server.util.javascript.JavaScriptTask.call(JavaScriptTask.java:113)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
I have a feeling this is due to the mismatched driver versions. Version 3.9 has the method indicated in the error, but 4.2 does not.
Once you get that sorted out, you are going to want to change this line
var jsonDoc = JSON.stringify(connectorMessage.getEncodedData(msg));
to this
var jsonDoc = connectorMessage.getEncodedData();
msg does not exist in a Javascript Writer, and connectorMessage.getEncodedData() does not take any parameters and returns a String. connectorMessage is an instance of ImmutableConnectorMessage from the Mirth User API.
I have a problem with my small demo for live query as in attached image.
To be honest, I have no idea why does it go wrong. Try to find some solutions around but not yet successfully. Please give me some ideas or solutions if you know this issue. Thanks so much.
Parse server example: 1.4.0
Parse JS SDK: 1.10.2
NodeJS: 8.9.1
npm: 5.5.1
P/S: I have added classes for supporting by Live Query already.
Here is the source which run successfully without using Live Query
Link to src with removed parse link:
var Parse = require('parse/node');
Parse.initialize("shetei5aeJ9Aequi6deejojiv7foh6Hieg2eesh9keingohw");
Parse.serverURL = 'serURLhere';
var Node = Parse.Object.extend('Node');
var q = new Parse.Query('Node');
var subscription = q.subscribe();
var procEventOpen = () => {
console.log('subscription opened...');
};
subscription.on('open', procEventOpen);
This happened to me when I had a typo in server url.
Try to explicit specify liveQueryServerURL parameter:
Parse.liveQueryServerURL = 'ws://yourserverurl/parse';
Note the ws instead of http(s)
Problem
I'm trying to create a simple trustless file sharing application. I'm using EasyRSA (https://github.com/paragonie/EasyRSA) to create a key-pair and then encrypt my data with the public key. I'm sending the private key to my JS wherein I'm using Node-RSA (https://github.com/rzcoder/node-rsa). Here, I try to decrypt using the previously created private key. But this happens:
Error
Uncaught Error: Error during decryption (probably incorrect key). Original error: Error: Incorrect data or key
at NodeRSA.module.exports.NodeRSA.$$decryptKey (drop.js:23265)
at NodeRSA.module.exports.NodeRSA.decrypt (drop.js:23213)
at window.onload (drop.js:22270)
My JS code looks something like this:
var NodeRSA = require('node-rsa');
window.onload = function() {
var key_val = $('#key').val();
var ciphertext = $('#encrypted').val();
var key = new NodeRSA();
key.importKey($('#key').val(), 'pkcs1');
var ciphertext_base = key.encrypt(ciphertext, 'base64');
var decrypted_base = key.decrypt(btoa(ciphertext));
console.log(decrypted);
}
I think this has got something to do with the incompatibility between the formats/key-sizes/algos used to create the keys. If someone could help me 'hack' this and make it work, I would be very grateful to you.
I have a small problem using mailparser. When I'm trying to see the subject content it says that is undefined.
My code looks something like this :
var fs = require("fs");
var socket = fs.createWriteStream('./outputmail.eml');
socket.on("end",function()
{
connection.loginfo("end------->");
});
connection.transaction.message_stream.pipe(socket, {}); // haraka related
var mailparser = new MailParser();
mailparser.on("end", function(mail_object){
connection.loginfo("----------SUBJECT-------------------->:", mail_object.subject);
});
fs.createReadStream("./outputmail.eml").pipe(mailparser);
I'm using mailparser in Haraka (http://haraka.github.io) . The whole point doing this, is that I want to parse every mail I receive and add a banner/image/whatever into the mail's body. If you have any idea why this message appears , please let me know.
If that is the code it is likely that you start reading the file before it is written. As the libraries both support streams you should be able to pipe the message_stream directly to mailparser, ie.
var mailparser = new MailParser();
mailparser.on("end", function(mail_object) {
console.log(mail_object);
});
connection.transaction.message_stream.pipe(mailparser, {});
Another reason could naturally be that there just isn't a subject in the email.
I'm using Mirth Connect (stable version) to create interfaces for HL7v3. I've created an interface to recieve a PRPA_IN201305UV02 message.
At this point I want to do some sort of validation of the incoming XML message. After some search I discovered that HL7 has schemas files (xsd) to verify the correctness of the messages.
So, I'm trying to implement the validation against a xsd file. Searching the mirth forum one of the administrators posted a link to a java library for xml validation.
In my channel source transformer I wrote the javascript based on that link.
// parse an XML document into a DOM tree
var parser = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
var document = parser.parse(msg);
The last line of code is getting me an error when I recieve a message
Wrapped java.net.MalformedURLException: no protocol
I tried also with
var document = parser.parse(messageObject.getRawData());
But I get the same error.
What is missing here?
Is this the best way to do a XML validation on Mirth Connect?
Thank you
I have found this answer
And I transformed that to Javascript in Mirth
var schemaFile = new Packages.java.io.File("C:\\schema.xsd");
var url = new Packages.java.net.URL("file:C:\\input.xml");
var xmlFile = new Packages.javax.xml.transform.stream.StreamSource(url);
var schemaFactory = Packages.javax.xml.validation.SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
var schema = schemaFactory.newSchema(schemaFile);
var validator = schema.newValidator();
try {
validator.validate(xmlFile);
logger.info('valid');
} catch (err) {
logger.error(err.toString());
}
You need to download JAXP (Java API for XML Processing) from here
I hope it helps others