ServiceNow Rest API call - rest

I am trying to use a between operator as below,
curl -k "https://instance.service-now.com/api/now/table/My_Table?sysparm_query=sys_updated_on>javascript:gs.dateGenerate('2017-12-06','14:45:23')^sys_updated_on<javascript:gs.dateGenerate('2017-12-08','14:45:23')" --request GET --header "Accept:application/json" --user 'My Username':'My Password'
The output that I get is not in between the specified date Limit. Is there anything that I am doing wrong with the Command. Is the above command built correctly?I am stuck with this and trying different ways. Can anybody help me?

I recommend using the BETWEEN query operator.
sysparm_query=sys_updated_onBETWEENjavascript:gs.dateGenerate('2017-12-06','14:45:23')#javascript:gs.dateGenerate('2017-12-08','14:45:23')
You should then URL-encode the query to make sure none of your characters would cause an issue:
sys_updated_onBETWEENjavascript%3Ags.dateGenerate(%272017-12-06%27%2C%2714%3A45%3A23%27)%40javascript%3Ags.dateGenerate(%272017-12-08%27%2C%2714%3A45%3A23%27)
Pro-tip: You can actually just go to the table and run the exact query you want to run, then right-click the query breadcrumb and click "Copy query" to get the exact query syntax you want.
More on this in my book: Learning ServiceNow. For a more advanced and shorter compendium of ServiceNow best-practices, pro-tips, and guidelines, check out my latest book: The ServiceNow Development Handbook.

Related

Search results using the github API

I am using the following query:
https://api.github.com/search/repositories?q=mysql&created:%3C2009-04-11&order=asc
and see the same results as:
https://api.github.com/search/repositories?q=mysql&created:%3E=2013-04-11&order=asc
Looks the created is not taking into effect.
can you please help me if I am missing anything in the query?
At document of REST API v3, parameters are added using +. So how about the following modification?
From :
https://api.github.com/search/repositories?q=mysql&created:<2009-04-11&order=asc
https://api.github.com/search/repositories?q=mysql&created:>=2013-04-11&order=asc
To :
https://api.github.com/search/repositories?q=mysql+created:<2009-04-11&order=asc
https://api.github.com/search/repositories?q=mysql+created:>=2013-04-11&order=asc
If I misunderstand your question, I'm sorry.
Edit :
When you want to retrieve the data using curl, please use as follows. In this case, please enclose the URL using double quotations. The URL in this sample is from your comments.
curl "https://api.github.com/search/repositories?q=python+created:%3E2009-04-11&page=1"
or
curl "https://api.github.com/search/repositories?q=python+created:>2009-04-11&page=1"

Get ads and their image in the same query

I'm using the graph API and trying to get a list of ads with their insights and post images.
I don't want to do multiple queries for this as I quickly hit the "(#17) User request limit reached" issue even when I use batch queries.
My current query looks like this:
/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative
Now in order to get the post image, I need to take the creative ID that is returned and use it in another query to pull the post like this:
/CREATIVE_ID/?fields=object_story_id
Then use the returned story id to pull the picture like:
/OBJECT_STORY_ID/?fields=picture
Is there any way I can combine these queries to do less requests?
Something like:
/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative{object_story_id{picture}}'
Any help is appreciated. Thanks.
Facebook's Batch API may work for you. It allows for multiple Graph API calls to be made from a single HTTP request and supports dependencies between those requests. Read over the documentation for details and here's a example curl call of how it might work (I've not executed this call so please review against the API documentation and test).
curl \
-F 'access_token=...' \
-F 'batch=[
{
"method":"GET",
"name":"ads",
"relative_url":"/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative",
},
{
"method":"GET",
"name":"creative",
"relative_url":"/{result=ads:$.data.*.creative}/?fields=object_story_id"
},
{
"method":"GET",
"relative_url":"/{result=creative:$.data.*.object_story_id}/?fields=picture"
}
]' \
https://graph.facebook.com

Nutch REST api Results (limited)

I've just figured out how to complete a Nutch crawl via the REST api for the 2.3 version of Nutch. You can see my post here. So after running the crawl, I go to MongoVue to check out the results and there is no "status" or "baseUrl" fields, along with others. Now if I do a normal crawl through cygwin, I get all fields. Is there some parameter I'm missing from the POST request to UPDATEDB call?
Here is the last call I make for Updatedb.
{
"args":{
"crawlId":"crawl-01",
"batch":"1428526896161-4430"
},
"confId":"default",
"crawlId":"crawl-01",
"type":"UPDATEDB"
}
I figured it out. The timestamp used in the GenerateJob step was wrong. It needed to be in a particular format and my code wasn't supporting it. Found a work around.

How to list objects and (virtual directorys) using the REST API for OpenStack Object Store(Swift)

we use the REST API for OpenStack Object Store(Swift).
guessing the following structure does exist in the OpenStack Object Store:
/containername/object1.txt
/containername/object2.txt
/containername/pseudo-directoryname/object3.txt
/containername/pseudo-directoryname/object4.txt
To get a list of objects from a container we can use a HTTP GET request with the specified URL.
So far so good. Result:
/object1
/object2.txt
/pseudo-directoryname/object3
/pseudo-directoryname/object4.txt
The GET request combined with a delimiter parameter ("URL+ABSOLUTEPATH?delimiter=/") cuts the pseudo directories from the result.
/object1.txt
/object2.txt
I would like to have a list of all objects within the container combined with the pseudo directories within the container.
Is there a solution to get the following result without getting all objects and parse them on client side?
/object1.txt
/object2.txt
/pseudo-directoryname/
I didn't find anything about wildcards when using the delimiter parameter.
Something like "URL+ABSOLUTEPATH?delimiter=/*/".
I was just trying to work the same thing out. Found the answer in the docs: http://docs.openstack.org/user-guide/cli_swift_pseudo_hierarchical_folders_directories.html#list-pseudo-hierarchical-folders-request-http
Using their example (note the prefix and delimiter query string parameters):
$ curl -X GET -i -H "X-Auth-Token: $token" $publicurl/v1/AccountString/backups?prefix=photos/&delimiter=/
Would return:
photos/animals/
photos/me.jpg
photos/plants/

Solr: Synonyms using the Managed Resources REST API

How do I change an initArgs value for Synonyms using the Managed Resources REST API?
In particular, I need to change the following:
"initArgs":{"ignoreCase":false}
... to true.
https://cwiki.apache.org/confluence/display/solr/Managed+Resources#ManagedResources-Synonyms
I don't see any mention in the documentation about changing initArgs.
You can edit the file directly after it has been created, but the docs explicitly say this is not the correct way to change data in this file. (it does work however).
found it. try&error style ;-)
curl -X POST -H 'Content-type:application/json' --data-binary '{"initArgs":{"ignoreCase":true}}' "http://<solr-host>/solr/<core>/schema/analysis/synonyms/german"