I would like to use the HAPI FHIR structures in my application. My application is a spring-boot application.
Code:
#RequestMapping(value = "{fhirVersion}/$transaction", method = RequestMethod.POST)
public String execute(#RequestBody Bundle bundle,#PathVariable String fhirVersion) {
return "";
}
Error:
{
"timestamp": "2018-04-03T15:06:51.279+0000",
"status": 415,
"error": "Unsupported Media Type",
"message": "Content type 'application/json;charset=UTF-8' not supported",
"path": "/dstu3/$transaction"
}
Could you please let me know how this could be achieved?
Thanks
Related
I have developed a call back REST service using the following link as reference https://docs.clickatell.com/channels/one-api/one-api-reference/#tag/One-API-Client-Callbacks/operation/sendPostOmniReplyCallback. I am using the sample payload as supplied by the Clickatell example using Postman and I can process and post the payload without problems. It also works when I deploy this as a public URL on the web. However, when pasting my URL in the Clickatell Customer Call Back I do not receive any call backs. I am obviously missing something or misinterpreting the sample code provided by Clickatell. Please note that for testing purposes I write the full payload to MySQL - works when using Postman, but not from Clickatell Call Back URL.
enter code here
{
[Route("client-callback/one-api-reply")]
[ApiController]
public class MessageController : ControllerBase
{
[HttpPost]
public async Task<dynamic> StartProcessiongAsync([FromBody] dynamic obj)
{
string myObj = JsonConvert.SerializeObject(obj);
var data = JsonConvert.DeserializeObject<Rootobject>(myObj);
var context = new DataContext();
var command = context.Database.GetDbConnection().CreateCommand();
context.Database.OpenConnection();
command = context.Database.GetDbConnection().CreateCommand();
{
command.CommandText =
"INSERT INTO testcallback(message) VALUES ('" + myObj + "');";
command.ExecuteNonQuery();
}
return Ok(obj);
}
}
}
Postman Payload Sample
{
"integrationId": "fa8090815f05d5ed015f0b5b56080cd2",
"integrationName": "My integration",
"event": {
"moText": [
{
"channel": "sms",
"messageId": "3a89680503414383af44dcd0e4e5f184",
"relatedMessageId": "d33eef0838a121f71069a4cc8d55c19e",
"relatedClientMessageId": "d33eef0838a121f71069a4cc8d55c19e",
"from": "2799900001",
"to": "2799900001",
"timestamp": 1506607698000,
"content": "Text Content of the reply message",
"charset": "UTF-8",
"sms": {
"network": "Network ID"
},
I´am following this tutorial tutorial login facebook xamarin to do login in facebook using xamarin, sometimes i get the following erro:
{
"error": {
"message": "Bad signature",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "AO97gtDS9YV3BPFzKKM4vUG"
}
}
I have the method, if i debug and get the variable requestUrl and put in browser i get the json erro above:
public async Task<FacebookProfile> GetFacebookProfileAsync(string accessToken)
{
var requestUrl = new Uri(string.Format("https://graph.facebook.com/v3.0/me/?fields=id,name,picture.width(500).height(500),email,gender&access_token={0}", WebUtility.UrlEncode(accessToken)));
var httpCliente = new HttpClient();
var response = await httpCliente.GetStringAsync(requestUrl);//the exception happens here
var facebookProfile = JsonConvert.DeserializeObject<FacebookProfile>(response);
return facebookProfile;
}
why this happen and How can i solve this problem?
I'm testing API queries and sending POST with such body:
{
"books": "12",
"available": "true",
"id": "qwe2323-2342rfws-23r2rfew"
}
I got 200 response - OK.
But when I add line break to one of the string data, e.g.:
{
"books": "12",
"available": "true",
"id": "qwe2323-2342rfws-23r
2rfew"
}
I got 500 "Unknown error".
My question: Can the server recognize this error and return a response, for example, WRONG_ID? In fact, I just added a line break character to the identifier string. In theory, the script should see the forbidden symbol without problems and return the corresponding error. Can I give such a recommendation to fix this error?
The payload is INVALID which generates an exception at the server and responded with 500 as it cannot understand the data payload.
To check the payload and show a INVALID JSON DATA or through any custom message, you can check the payload on every POST request at the server side, as in below example for PHP programming language:
private function handleRequest(Request $request, Programmer $programmer)
{
// ...
if ($data === null) {
throw new \Exception(sprintf('Invalid JSON: '.$request->getContent());
}
// ...
}
Reference:
https://knpuniversity.com/screencast/rest/error-invalid-json#handling-invalid-json
I created Java files from SOAP WSDL and called the operation of WSDL from Adapter JS file. On returning the string I am getting below error.
"isSuccessful": false,
"warnings": [],
"errors": [
"Runtime: Procedure return value must be a Javascript Object, it is currently a String."
],
"info": []
This is my procedure:
function callSoap(CustId){
var callMethod = new com.idea.actions.SoapCallUtil();
var custBalance= callMethod.getBalance(CustId);
return custBalance;
}
How to convert this "custBalance" String in Javascript Object.Someone please help me how to resolve this.
The return value from an HTTP adapter should be a proper JSON.
Modify your current code from :
return custBalance;
to
return { myResponse : custBalance};
or
var resp = JSON.stringify(custBalance);
return {myResponse: resp};
I write a controller and it contain multi POST action but whene i post data to these actions my response is :
{ "name": "The request has been black-holed", "url": "/rest_sms_boxs.json" }
Now how can i resolve this problem.
Certainly the security mode.
Try in your controller:
public function beforeFilter()
{
parent::beforeFilter();
$this->Security->unlockedActions = array('your_method');
}