Sending json data as raw-json not working - postman - json

I'm trying to make a post-call API of Callpicker following these instructions:
I tried to make the post-call as JSON but it shows this error:
[raw_json_picture][1]
JSON CODE
[1]: https://i.stack.imgur.com/5Q2Ad.png
{
"token": "1d7af606e28caa8321bbdfe9c58cf0900b4c114977141645687dd6e4c697aa605bebaa36aeb5233b9764fc0f68cd670930792c83caa173f775b4491ae2435e0c",
"datetime": "now",
"first_call": "{'destination_type':'Extension','destination_id':'201539'}",
"second_call": "{'destination_type':'Phone','destination_id':'4731938483'}",
"preferred_trunk": "524831115864"
}
Also, I tried another way and made the post-call like this:
Header
Body
But it didn't work either ... I don't know what is wrong
I appreciate your help! thanks in advance.

I have tried your API and use the application/json Content-Type when setting the first_call and second_call parameter in the form-data. It worked!
Hope this helps!

Related

Using FeedIron to remove links from TT-RSS feeds

I'm trying to come up with a formula to remove all links from a feed's content. I'm using FeedIron on TT-Rss.
This is what I've got so far:
{
"url": "example.com",
"type": "regex",
"pattern": "^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$",
"replace": " "
}
I'm guessing that's already wrong(it's throwing an "Invalid JSON" error), but then again I'm not specialized at all. I just want to be able to receive the feeds without random links in the article content. Be it media links or any kind of link.
Can someone please help me? Thank you!
Maintainer of Feediron here.
Feediron doesn't work on the Article stub that comes in the RSS feed. It fetches the page source and then you modify the returned data.
The reason it's throwing a Invalid JSON error is because you have to escape the special characters in your regex.
E.G. using the website: https://www.freeformatter.com/json-escape.html
^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
Becomes:
^(http:\\\/\\\/www\\.|https:\\\/\\\/www\\.|http:\\\/\\\/|https:\\\/\\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\\/.*)?$
Also your configuration is not a correct format the example regex config:
"example.tld":{
"type":"xpath",
"xpath":"article",
"reformat": [
{
"type": "regex",
"pattern": "^(http:\\\/\\\/www\\.|https:\\\/\\\/www\\.|http:\\\/\\\/|https:\\\/\\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\\/.*)?$",
"replace": " "
}
]
}
Also note in the Testing tab you need to drop the domain "example.tld": for it to work

Angular 5 httpClient get Request vscode json error

My code is working perfectly, I just have a problem where my data from the get request is underlined in red and I don't understand how to fix this. The alert works perfectly. It alerts the SessionID that I need. I would just like to know how I can remove this underlined error, or maybe I am not doing the get request correctly? Thank you for any help :)
try below code :
this.httpClient.get('hidden').subscribe((myData:any)=>{
alert(myData.utLogon_responce.sessionId)
})
add : any
thanks,
The red wiggly lines that show up are indicating the type error. This indicates that it cannot determine the utLogon_response in type definition of myData variable. This can be solved by either of following ways:
Make myData as type any (simple, quick and easier)
this.httpClient.get('hidden')
.subscribe((myData: any) => {
alert(myData.utLogon_response.sessionId);
})
However, my understanding is that one should use any only in extreme conditioms since this is more like defeating the very purpose of Typescript.
Define proper type for myData and use it (simple, slight coding but most appropriate)
interface IHiddenData {
utLogon_response: any {
sessionId: string;
}
}
this.httpClient.get('hidden')
.subscribe((myData: IHiddenData) => {
alert(myData.utLogon_response.sessionId);
})
I hope this helps!
NOTE: Somehow, this code is not getting properly formatted by the editor and I do know how to set it right.

Make fields inside a JSON response clickable (url) on a JSP page

I wish to display the JSON response returned from a REST API call "as-is" on a JSP. The problem I'm facing here is that the response is in a single line like below.
{"result":[{"enable":"true","time_stamp":"2018-01-26 19:31:37","url":"abc.xyz.com","group_id":"one"},{"enable":"false","time_stamp":"2018-01-26 19:31:37","url":"lmn.pqr.com","group_id":"two"}]}
I would like it to be displayed in a well-formatted JSON response, something like below for sorts.
{
"result":[
{
"enable":"true",
"time_stamp":"2018-01-26 19:31:37",
"url":"abc.xyz.com",
"group_id":"one"
},
{
"enable":"false",
"time_stamp":"2018-01-26 19:31:37",
"url":"lmn.pqr.com",
"group_id":"two"
}
]
}
Having said that, there are certain url ("url":"abc.xyz.com")parameters in the JSON response, which I would want to be clickable, so that users can see the JSON response dumped on the web page, but be able to click on the URL field's value to navigate to the different page.
Any idea of how this could be achieved?
Just use JSON.stringify and a HTML tag of pre
Here is a fiddle demo
or if your use AngularJs use:
<pre>{{jsonData|json}}</pre>

Display JSON object nicely with Syntax Hihjlighter

I'm trying to display a JSON object nicely (this means on several lines with indentation) with Alex Gorbatchev plugin : http://alexgorbatchev.com/SyntaxHighlighter/
Unfortunately, it all displays on a single line.
I'm using the javascript brush.
I've created a code pen : http://codepen.io/hugsbrugs/pen/XJVjjP?editors=101
var json_object = {"hello":{"my_friend":"gérard", "my_dog":"billy"}};
$('#nice-json').html('<pre class="brush: javascript">' + JSON.stringify(json_object) + '</pre>');
SyntaxHighlighter.highlight();
Please don't give a list of other plugins since I know there is a bunch but I don't want to load additional plugins ... I'd like to achieve it with this plugin.
Thanks for your help
Try indenting the json with the stringify method.
JSON.stringify(json_object, undefined, 2);
You can use the optional third parameter of JSON.stringify(...) which is the space argument.
Change:
JSON.stringify(json_object)
to:
JSON.stringify(json_object, null, '\t')
Here is your codepen updated to show the result of the above modifications. The above modification causes your JSON to be pretty printed over multiple lines.

Parse JSON from Joomla K2 website

I'm trying to get JSON from my k2 powered Joomla website. As I understood, I need to add index.php?option=com_k2&id=1&lang=mk&task=category&view=itemlist&format=json to my URL, and then it downloads a joomla.json file. As I know now I need to parse this content but I'm suspicious about the correct format in the joomla.json file.
Here is part of the content of the json file:
{"id":"6","title":"\u0424\u0443\u0441\u0442\u0430\u043d \u041a\u0440\u0438\u0441\u0442\u0438\u043d\u0430","alias":"fustan-kristina","link":"\/katalog\/vencanici\/fustan-kristina.html","catid":"1","introtext":"<ul>\r\n<li>\u041e\u0432\u043e\u0458 \u0444\u0443\u0441\u0442\u0430\u043d \u0435 \u0438\u0437\u0440\u0430\u0431\u043e\u0442\u0435\u043d \u043e\u0434 100% \u0441\u0432\u0438\u043b\u0430.<\/li>\r\n<li>\u041d\u0435\u0436\u0435\u043d \u043c\u0430\u0442\u0435\u0440\u0438\u0458\u0430\u043b<\/li>\r\n<li>\u0414\u043e\u0434\u0430\u0434\u0435\u043d\u0438 \u0446\u0438\u0440\u043a\u043e\u043d\u0438<\/li>\r\n<\/ul>\r\n<p>\u0412\u0438\u0441\u0442\u0438\u043d\u0441\u043a\u0438 \u043d\u0435\u0432\u0435\u0441\u0442\u0438\u043d\u0441\u043a\u0438 \u0444\u0443\u0441\u0442\u0430\u043d<\/p>\r\n<p>\u0411\u0443\u0442\u0438\u043a \u0412\u0438\u043a\u0442\u043e\u0440<\/p>","fulltext":"","extra_fields":[{"id":"1","name":"\u0426\u0435\u043d\u0430","value":"12000 \u0434\u0435\u043d.","type":"textfield","group":"1","published":"1","ordering":"1"},{"id":"6","name":"\u0412\u0435\u0431 \u0421\u0442\u0440\u0430\u043d\u0430","value":"<a href=\"http:\/\/www.domain.mk\" target=\"_blank\">http:\/\/www.domain.mk<\/a>","type":"link","group":"1","published":"1","ordering":"2"}],"created":"2012-07-11 09:42:04","created_by_alias":"","modified":"2012-07-11 11:26:34","featured":"0","image":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_S.jpg","imageWidth":"200","image_caption":"\u0424\u0443\u0441\u0442\u0430\u043d \u041a\u0440\u0438\u0441\u0442\u0438\u043d\u0430","image_credits":"","imageXSmall":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_XS.jpg","imageSmall":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_S.jpg","imageMedium":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_M.jpg","imageLarge":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_L.jpg","imageXLarge":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_XL.jpg","video":null,"video_caption":"","video_credits":"","gallery":null,"hits":"50","category":{"id":"1","name":"\u0412\u0435\u043d\u0447\u0430\u043d\u0438\u0446\u0438","alias":"vencanici","link":"\/katalog\/katalog\/vencanici.html","description":"","image":"","ordering":"1"},"tags":[{"id":"1","name":"kristina","published":"1","link":"\/tag\/kristina.html"},{"id":"2","name":"fustan","published":"1","link":"\/tag\/fustan.html"},{"id":"3","name":"vencanica","published":"1","link":"\/tag\/vencanica.html"}],"attachments":[],"votingPercentage":100,"numOfvotes":"(1 \u0413\u043b\u0430\u0441\u0430\u0458)","author":{"name":"\u0414\u0430\u0440\u043a\u043e \u041f\u0435\u0442\u043a\u043e\u0432\u0441\u043a\u0438","link":"\/blog\/\u0414\u0430\u0440\u043a\u043e-\u041f\u0435\u0442\u043a\u043e\u0432\u0441\u043a\u0438.html","avatar":"http:\/\/www.gravatar.com\/avatar\/bb9f8918a0a63b260d46eb419bf1a894?s=100&default=http%3A%2F%domain.mk%2Fcomponents%2Fcom_k2%2Fimages%2Fplaceholder%2Fuser.png","profile":{"gender":null}},"numOfComments":"0","events":{"BeforeDisplay":"","AfterDisplay":"","AfterDisplayTitle":"","BeforeDisplayContent":"","AfterDisplayContent":"","K2BeforeDisplay":"","K2AfterDisplay":"","K2AfterDisplayTitle":"","K2BeforeDisplayContent":"","K2AfterDisplayContent":"","K2CommentsCounter":""}}]}
Is this json in the correct format,and is this the method that I'm doing correct to get json content from my K2 website?
You are having an extra ] and } at the end of your JSON String.
After removing them, your JSON turns out fine and legit.
{"id":"6","title":"\u0424\u0443\u0441\u0442\u0430\u043d \u041a\u0440\u0438\u0441\u0442\u0438\u043d\u0430","alias":"fustan-kristina","link":"\/katalog\/vencanici\/fustan-kristina.html","catid":"1","introtext":"<ul>\r\n<li>\u041e\u0432\u043e\u0458 \u0444\u0443\u0441\u0442\u0430\u043d \u0435 \u0438\u0437\u0440\u0430\u0431\u043e\u0442\u0435\u043d \u043e\u0434 100% \u0441\u0432\u0438\u043b\u0430.<\/li>\r\n<li>\u041d\u0435\u0436\u0435\u043d \u043c\u0430\u0442\u0435\u0440\u0438\u0458\u0430\u043b<\/li>\r\n<li>\u0414\u043e\u0434\u0430\u0434\u0435\u043d\u0438 \u0446\u0438\u0440\u043a\u043e\u043d\u0438<\/li>\r\n<\/ul>\r\n<p>\u0412\u0438\u0441\u0442\u0438\u043d\u0441\u043a\u0438 \u043d\u0435\u0432\u0435\u0441\u0442\u0438\u043d\u0441\u043a\u0438 \u0444\u0443\u0441\u0442\u0430\u043d<\/p>\r\n<p>\u0411\u0443\u0442\u0438\u043a \u0412\u0438\u043a\u0442\u043e\u0440<\/p>","fulltext":"","extra_fields":[{"id":"1","name":"\u0426\u0435\u043d\u0430","value":"12000 \u0434\u0435\u043d.","type":"textfield","group":"1","published":"1","ordering":"1"},{"id":"6","name":"\u0412\u0435\u0431 \u0421\u0442\u0440\u0430\u043d\u0430","value":"<a href=\"http:\/\/www.domain.mk\" target=\"_blank\">http:\/\/www.domain.mk<\/a>","type":"link","group":"1","published":"1","ordering":"2"}],"created":"2012-07-11 09:42:04","created_by_alias":"","modified":"2012-07-11 11:26:34","featured":"0","image":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_S.jpg","imageWidth":"200","image_caption":"\u0424\u0443\u0441\u0442\u0430\u043d \u041a\u0440\u0438\u0441\u0442\u0438\u043d\u0430","image_credits":"","imageXSmall":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_XS.jpg","imageSmall":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_S.jpg","imageMedium":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_M.jpg","imageLarge":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_L.jpg","imageXLarge":"\/media\/k2\/items\/cache\/ada9a09acea936d776a6f55c82778c43_XL.jpg","video":null,"video_caption":"","video_credits":"","gallery":null,"hits":"50","category":{"id":"1","name":"\u0412\u0435\u043d\u0447\u0430\u043d\u0438\u0446\u0438","alias":"vencanici","link":"\/katalog\/katalog\/vencanici.html","description":"","image":"","ordering":"1"},"tags":[{"id":"1","name":"kristina","published":"1","link":"\/tag\/kristina.html"},{"id":"2","name":"fustan","published":"1","link":"\/tag\/fustan.html"},{"id":"3","name":"vencanica","published":"1","link":"\/tag\/vencanica.html"}],"attachments":[],"votingPercentage":100,"numOfvotes":"(1 \u0413\u043b\u0430\u0441\u0430\u0458)","author":{"name":"\u0414\u0430\u0440\u043a\u043e \u041f\u0435\u0442\u043a\u043e\u0432\u0441\u043a\u0438","link":"\/blog\/\u0414\u0430\u0440\u043a\u043e-\u041f\u0435\u0442\u043a\u043e\u0432\u0441\u043a\u0438.html","avatar":"http:\/\/www.gravatar.com\/avatar\/bb9f8918a0a63b260d46eb419bf1a894?s=100&default=http%3A%2F%domain.mk%2Fcomponents%2Fcom_k2%2Fimages%2Fplaceholder%2Fuser.png","profile":{"gender":null}},"numOfComments":"0","events":{"BeforeDisplay":"","AfterDisplay":"","AfterDisplayTitle":"","BeforeDisplayContent":"","AfterDisplayContent":"","K2BeforeDisplay":"","K2AfterDisplay":"","K2AfterDisplayTitle":"","K2BeforeDisplayContent":"","K2AfterDisplayContent":"","K2CommentsCounter":""}}
Use this site to test your JSON String.
http://jsonlint.com/
If you are having difficulty visualizing your JSON String in 3D, try http://jsonviewer.stack.hu/ You could format the String to visualize the JSON.
I am using &format=json too to bulid my website.
$.get('//url with format=json',function(d){$('.k2ItemTitle').html(d.item.title)})
I don't even have to use $.pareJSON