web stats
Swagger documentation issue - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-07-2016, 04:28 AM
vishal423 vishal423 is offline
What's HL7?
 
Join Date: Jun 2016
Posts: 5
vishal423 is on a distinguished road
Question Swagger documentation issue

While trying to consume Mirth Connect client APIs via Swagger documentation, I am able to consume GET APIs, however, with POST I am facing issues. For example, if I try to consume POST API to send a message to channel, it tries to send with header Content-Type: application/xml' whereas the body is of JSON type. Refer below curl request, response and error message.

curl -X POST --header 'Content-Type: application/xml' --header 'Accept: text/html' -d '{
"overwrite": false,
"imported": false,
"originalMessageId": 0,
"rawData": "string",
"rawBytes": [
"string"
],
"destinationMetaDataIds": [
0
],
"sourceMap": {},
"binary": false
}' 'https://localhost:9443/api/channels/1212121/messages'

and response :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 </title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /api/channels/1700876a-2c55-451f-8b90-2b44e563de37/messages. Reason:
<pre> Request failed.</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>

Server logs following stack trace (only root cause for brevity):
Caused by: org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not { (position: START_DOCUMENT seen {... @1:1)


Could you please suggest on how to consume POST requests using swagger documentation or any external REST client like POSTMAN? Also, are there any examples that I can refer to get sample body of POST requests?
--
~Vishal

Last edited by vishal423; 07-07-2016 at 05:38 AM. Reason: after more debugging, it appears to be an issue
Reply With Quote
  #2  
Old 07-07-2016, 07:14 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

This is one place that admittedly needs additional work in our Client API documentation.

Swagger (the models we use for documenting our JAX-RS interfaces) just takes the Java objects required, converts them to JSON, and displays that as the "Model Schema". But really most of our endpoints only support XML not JSON (yet).
__________________
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
  #3  
Old 07-08-2016, 01:26 AM
vishal423 vishal423 is offline
What's HL7?
 
Join Date: Jun 2016
Posts: 5
vishal423 is on a distinguished road
Default

I believe we can specify xml attributes in swagger spec to represent model in XML format, but, will debug more on how to achieve it. For now, have to really look into source code to understand object structure and able to consume message POST API
Reply With Quote
  #4  
Old 05-24-2017, 11:38 AM
enigmasse enigmasse is offline
What's HL7?
 
Join Date: Apr 2017
Posts: 1
enigmasse is on a distinguished road
Default

What is an example XML payload for this endpoint (https://localhost:8444/api/channels/{abc}/messages)?

Last edited by enigmasse; 05-25-2017 at 06:17 AM.
Reply With Quote
  #5  
Old 08-09-2017, 11:31 PM
carles carles is offline
OBX.2 Kenobi
 
Join Date: Mar 2007
Location: Girona
Posts: 62
carles is an unknown quantity at this point
Default

I'm on the same issue.
I tried to made up a XML payload for https://localhost:8444/api/channels/{abc}/messages endpoint but without success

Code:
<rawMessage>
	<overwrite>false</overwrite>
	<imported>false</imported>
	<originalMessageId>0</originalMessageId>
	<rawData>string</rawData>
	<rawBytes>string</rawBytes>
	<destinationMetaDataIds>0</destinationMetaDataIds>
	<sourceMap />
	<binary>false</binary>
</rawMessage>
Anybody knows what would be?
thanks
Reply With Quote
  #6  
Old 08-10-2017, 07:15 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Here's an example:

Code:
<com.mirth.connect.donkey.model.message.RawMessage>
	<rawData>testing</rawData>
	<binary>false</binary>
</com.mirth.connect.donkey.model.message.RawMessage>
__________________
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 08-10-2017, 10:39 PM
carles carles is offline
OBX.2 Kenobi
 
Join Date: Mar 2007
Location: Girona
Posts: 62
carles is an unknown quantity at this point
Default

it works fine!

thanks
Reply With Quote
Reply

Tags
swagger

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 10:20 AM.


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