web stats
Send Json to Rest WebService - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-24-2017, 01:21 AM
lgiuriollo lgiuriollo is offline
Mirth Newb
 
Join Date: Sep 2016
Posts: 17
lgiuriollo is on a distinguished road
Default Send Json to Rest WebService

I'm trying to send a json generated in my transformer.

This Json is already validated, and accepted on my client, but via mirth the same displays Invalid Json error.

I'm sending the channel attached, could you give me an aid on this case?

Thank you,
Leandro
Attached Files
File Type: xml IntegraHCBarretos - Request.xml (91.0 KB, 66 views)

Last edited by lgiuriollo; 01-24-2017 at 01:33 AM.
Reply With Quote
  #2  
Old 01-24-2017, 12:27 PM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
 
Join Date: Sep 2014
Location: Michigan
Posts: 570
kirbykn2 is on a distinguished road
Default

What is the error?
__________________
Kirby

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.11.2
Mirth Connect Version 3.6.1
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_151-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.6.3
Reply With Quote
  #3  
Old 01-25-2017, 02:11 AM
lgiuriollo lgiuriollo is offline
Mirth Newb
 
Join Date: Sep 2016
Posts: 17
lgiuriollo is on a distinguished road
Default

Quote:
Originally Posted by kirbykn2 View Post
What is the error?
HTTP Sender error
ERROR MESSAGE: JSON or XML content is obligatory for fulfilment of this request.


But i'm have a validated Json with PostMan... =/
Reply With Quote
  #4  
Old 01-25-2017, 04:05 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

Are you sure you are passing the JSON as payload to the URL? Did you check whether it is empty?
Reply With Quote
  #5  
Old 01-25-2017, 05:32 AM
lgiuriollo lgiuriollo is offline
Mirth Newb
 
Join Date: Sep 2016
Posts: 17
lgiuriollo is on a distinguished road
Default

Quote:
Originally Posted by siddharth View Post
Are you sure you are passing the JSON as payload to the URL? Did you check whether it is empty?

Mirth send charset in header:

POST http://127.0.0.1:8888/api/receiver/request HTTP/1.1
charset:
Content-Type: application/json; charset=windows-1252
Content-Length: 427
Host: 127.0.0.1:8888
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.1 (Java/1.8.0_121)
Accept-Encoding: gzip,deflate

if i remove charset=windows-1252 the process is ok...

but i don't know remove charset in mirth...
Attached Images
File Type: png teste.png (4.0 KB, 31 views)
Reply With Quote
  #6  
Old 01-25-2017, 06:19 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

It looks like an error with the server you're sending to. It's probably coded poorly and is checking for a Content-Type that literally matches "application/json" without correctly parsing out elements of the header value.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #7  
Old 02-03-2017, 09:15 AM
lgiuriollo lgiuriollo is offline
Mirth Newb
 
Join Date: Sep 2016
Posts: 17
lgiuriollo is on a distinguished road
Default

i'm tryed send json in webservice, using this code:


function RISToDeliveryReport(JsonFile, URL) {

try {

var data = JsonFile;

// Create url object
var url = new java.net.URL(URL);

// Open connection to url
var conn = url.openConnection();


conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-length", data.length());
conn.setRequestProperty("Content-type", "application/json");

logger.info("teste1");


// Send request
var outStream = conn.getOutputStream();
var outWriter = new java.io.OutputStreamWriter(outStream);
outWriter.write(data);
outWriter.close();

logger.info("teste2");

// Get response
var inputStream = conn.getInputStream();
logger.info("teste3");
var streamReader = new java.io.InputStreamReader(inputStream);
var respStream = new java.io.BufferedReader(streamReader);

logger.info("teste4");

//create variable to hold return data
var buffer = new java.lang.StringBuffer();
var line = null;
while ((line = respStream.readLine()) != null) {
buffer.append(line + 'n');
}
respStream.close();

logger.info("teste5");

// Store response in channelMap
var response = buffer.toString();
channelMap.put('response', response);

}//catch(exception){
//throw exception
//}

finally {

}
}


and a have problem in var inputStream = conn.getInputStream();

return this error:


ERROR (com.mirth.connect.server.userutil.DatabaseConnect ionFactory:165): Error initializing DatabaseConnectionFactory driver: null
java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.mirth.connect.server.userutil.DatabaseConnecti onFactory.initializeDriverAndGetInfo(DatabaseConne ctionFactory.java:155)
at com.mirth.connect.server.userutil.DatabaseConnecti onFactory.getCustomDriverInfo(DatabaseConnectionFa ctory.java:163)
at com.mirth.connect.server.userutil.DatabaseConnecti onFactory.createDatabaseConnection(DatabaseConnect ionFactory.java:53)
at sun.reflect.GeneratedMethodAccessor42.invoke(Unkno wn Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox. java:126)
at org.mozilla.javascript.NativeJavaMethod.call(Nativ eJavaMethod.java:225)
at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1479)
at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:393)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3280)
at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:120)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.executeScript(JavaScriptTask.java:142)
at com.mirth.connect.connectors.js.JavaScriptDispatch er$JavaScriptDispatcherTask.doCall(JavaScriptDispa tcher.java:149)
at com.mirth.connect.connectors.js.JavaScriptDispatch er$JavaScriptDispatcherTask.doCall(JavaScriptDispa tcher.java:122)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)




any ideia for this problem?


Thank's,
Leandro
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:43 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation