I'm using the Chrome Advanced Rest Client to test the AtTask API. I'm getting a lot of stuff figured out, but also getting some unexpected results. The latest is when adding new records to the AtTask Time Off Calendar.
I am able to easily add time off to the calendar. I am use the POST method, with the following URL:
https://COMPANY.attasksandbox.com/attask/api/v4.0/resvt?sessionID=SESSIONIDGOESHERE&userID=USERIDGOESHERE&startDate=2014-11-24T00:00:00&endDate=2014-11-28T23:59:59
This mark all the days between 11/24 through 11/28 as time off. Great, so far. The problem is that it removes all other rime-off records for the specified user. I am not issuing a DELETE, so I'm not understanding whey the records are being deleted. More importantly, I'm not understanding how to keep them from being deleted.
Once again, thanks in advance.
Time-off in attask is stored as a collection and when you make an edit to a collection it will replace the collection data with the date provided in the update. This is why your call is removing existing data.
In order to add a new time-off you will need to make 2 calls 1 to get exsisting time-off and one to enter the data back with the new dates.
note-I am using my own data so dates are a bit different for me but concept is same
Your get call will be
GET /api/resvt/search?userID=[userID]&fields=endDate,startDate,ID
which returns something like
{
"data": [
{
"ID": "547debb6000dea62198bd66b7c73e174",
"objCode": "RESVT",
"endDate": "2014-07-08T23:59:00:163-0600",
"startDate": "2014-07-08T00:00:00:163-0600"
},
{
"ID": "547debb6000dea61b8c695ba24918fe8",
"objCode": "RESVT",
"endDate": "2014-02-13T23:59:00:329-0700",
"startDate": "2014-02-13T00:00:00:329-0700"
}
]
}
Once you have this you can add your new time off to the collection using an updates command on the user object. Notice you are providing IDs to the time-off that is already in the system and the new time-Off you are providing no ID
PUT /attask/api/v4.0/user/[userID]?&sessionID=[sessionID]&updates={reservedTimes: [ { "ID": "547debb6000dea62198bd66b7c73e174", "objCode": "RESVT", "endDate": "2014-07-08T23:59:00:163-0600", "startDate": "2014-07-08T00:00:00:163-0600" }, { "ID": "547debb6000dea61b8c695ba24918fe8", "objCode": "RESVT", "endDate": "2014-02-13T23:59:00:329-0700", "startDate": "2014-02-13T00:00:00:329-0700" }, { "objCode": "RESVT", "endDate": "2014-02-14T23:59:00:329-0700", "startDate": "2014-02-14T00:00:00:329-0700" } ] }
This is a bit bulky and complex but is the only way to do this in the API at this time.
Related
I've using CK Web services very successfully, but I am stumped about how to create a CKReference.
I've looked at the docs here re Reference Dictionaries, but can't make such a dictionary work.
My php generates the following operations dictionary:
{"operations":[
{"operationType": "create",
"record": { "recordType": "Works",
"fields": {
"type":{"value":"Painting"},
"title": {"value":"test"},
"date": {"value":"10/29/1965"},
"height": {"value":"21"},
"length": {"value":"21"},
"width": {"value":"21"},
"runningTime": {"value":""},
"materials": {"value":"test"},
"description":{"value":"test"},
"saleStatus": {"value":"yes"},
"tos":{"value":"yes"},
"artist": {"value":"Peter Wiley"},
"artistRecordName":{"value":"286CB3BF-69CC-4DD3-9233-CC80E5FA95D4"},
"artistRecordRef": {
"recordName": {"value":"286CB3BF-69CC-4DD3-9233-CC80E5FA95D4"},
"zoneID":{"zoneName": {"value":"_defaultZone"}},
"action": {"value":"NONE"}
},
"subject":{"value":""},
"metaType":{"value":"Fine Art"},
"userRecordName":{"value":"30C54AD8-3701-428C-99B7-0393DD2DAB45"},
"userRole":{"value":"Artist"},
"status":{"value":"P"}
}
} }
]}
This request returns the error:
BAD_REQUEST" [1]=> string(62) "BadRequestException: Unexpected input
at [line: 26, column: 3]
If I remove the "artistRecordRef" the request works as it should.
I am sure the answer is obvious to a more experienced eye. Can someone see what's wrong?
OK, I found the answer here, but have posted for others who may have the question because the answer was not easy to find.
This is what works:
"artistRecordRef": {"value": {
"recordName": "'.$artistRecordName.'",
"action": "NONE"
}
},
The Reference Dictionary has to be passed as a value. I didn't get this and it's not well documented with examples in the Apple docs (at least in those I was able to find).
See: How can I use CloudKit web services to query based on a reference field?
I'm using Facebook Lead Ads API. I need to retrieve all fields from a form by ID. I know I can:
get all forms by calling /<PAGE_ID>/leadgen_forms, but it doesn't return the fields
get a form by /<FORM_ID>, but it displays only the name and a few
data, but not fields
get all leads by /<FORM_ID>/leads - it gives me the fields in each
lead, but only if I have leads; there's also another problem with this solution - the order of the fields is random
Is there any dedicated way to retrieve leadgen form fields, even when there are no leads yet?
I found out that I can download the CSV and in the first row, it gives me all fields IDs (and some other columns). I'm not sure though how I can read the content of this file in PHP, because it gives me some HTML when I try to use get_file_contents() on it.
You can get these by adding non-default field questions, so the url becomes /<form_id>?fields=id,name,questions.
The official docs don't describe the fields available for reading but the questions field and its nested fields are described in the params used for creating a lead form.
Example output
{
"id": "1234567890000",
"name": "test form",
"questions": [
{
"key": "name",
"label": "Full Name",
"type": "FULL_NAME",
"id": "777888999000111"
},
{
"key": "email",
"label": "Email Address",
"type": "EMAIL",
"id": "111222333444555"
}
]
}
Just a warning since this answer comes first on google search.
Since Facebook API v5.0 field "qualifiers" is removed and will throw an error.
Replace it with "questions" which is similar (if not exact) syntax as qualifiers. Found out the hard way on production server...
I am trying to delete a document from Solr using deleteByQuery.
The issue I am getting is that whenever I am trying to delete the document uniquely using only id, it is working fine.
However, when I am trying to delete based on more than one attribute, it is deleting all the documents where it finds even one attribute.
For eg,
if I have two documents say :
{
"id": "232",
"Author": "DEFG",
"Name": "Alphabet",
"Description": "Franz jagt im komplett verwahrlosten Taxi quer durch Bayern",
"_version_": 1513077984291979300
},
{
"id": "231",
"Author": "ABCD",
"Name": "Alphabet",
"Description": "Franz jagt im komplett verwahrlosten Taxi quer durch Bayern",
"_version_": 1513077999721775000
}
and I want to delete the document where id is 231 and Author is "ABCD", I wrote this query to delete that particular document.
$id=231;
$author= "ABCD";
$client->deleteByQuery("id:$id, Author:$author");
$client->commit();
It is deleting both the documents with id 231 and id 232 rather than deleting only one.
Can anyone please resolve this issue or give me any solution so that I can achieve this?
Thanks.
The delete query uses the same syntax as a search query. So you can easily test that query and tune it until it works. In your case, I suspect just doing id:$id AND Author:$author should work.
I'm currently trying to find all the pages where images/media from a particular category are being used on Wikimedia Commons.
Using the API, I can list all the images with no problem, but I'm struggling to make the query add in all the pages where the items are used.
Here is an example category with only two media images
https://commons.wikimedia.org/wiki/Category:Automobiles
Here is the API call I am using
https://commons.wikimedia.org/w/api.php?action=query&prop=images&format=json&generator=categorymembers&gcmtitle=Category%3AAutomobiles&gcmprop=title&gcmnamespace=6&gcmlimit=200&gcmsort=sortkey
The long term aim is to find all the pages the images from our collections appear on and then get all the tags from those pages about the images. We can then use this to enhance our archive of information about those images and hopefully used linked data to find relevant images we may not know about from DBpedia.
I might have to do two queries, first get the images then request info about each page, but I was hoping to do it all in one call.
Assuming that you don't need to recurse into subcategories, you can just use a prop=globalusage query with generator=categorymembers, e.g. like this:
https://commons.wikimedia.org/w/api.php?action=query&prop=globalusage&generator=categorymembers&gcmtitle=Category:Images_from_the_German_Federal_Archive&gcmtype=file&gcmlimit=200&continue=
The output, in JSON format, will looks something like this:
// ...snip...
"6197351": {
"pageid": 6197351,
"ns": 6,
"title": "File:-Bundesarchiv Bild 183-1987-1225-004, Schwerin, Thronsaal-demo.jpg",
"globalusage": [
{
"title": "Wikipedia:Fotowerkstatt/Archiv/2009/M\u00e4rz",
"wiki": "de.wikipedia.org",
"url": "https://de.wikipedia.org/wiki/Wikipedia:Fotowerkstatt/Archiv/2009/M%C3%A4rz"
}
]
},
"6428927": {
"pageid": 6428927,
"ns": 6,
"title": "File:-Fernsehstudio-Journalistengespraech-crop.jpg",
"globalusage": [
{
"title": "Kurt_von_Gleichen-Ru\u00dfwurm",
"wiki": "de.wikipedia.org",
"url": "https://de.wikipedia.org/wiki/Kurt_von_Gleichen-Ru%C3%9Fwurm"
},
{
"title": "Wikipedia:Fotowerkstatt/Archiv/2009/April",
"wiki": "de.wikipedia.org",
"url": "https://de.wikipedia.org/wiki/Wikipedia:Fotowerkstatt/Archiv/2009/April"
}
]
},
// ...snip...
Note that you will very likely have to deal with query continuations, since there may easily be more results than MediaWiki will return in a single request. See the linked page for more information on handling those (or just use an MW API client that handles them for you).
I don't understand your use case ("our collections"?) so I don't know why you want to use the API directly, but if you want to recurse in categories you're going to do a lot of wheel reinvention.
Most people use the tools made by Magnus Manske, creator of MediaWiki: in this case it's GLAMourous. Example with 3 levels of recursion (finds 186k images, 114k usages): https://tools.wmflabs.org/glamtools/glamorous.php?doit=1&category=Automobiles&use_globalusage=1&depth=3
Results can also be downloaded in XML format, so it's machine-readable.
We are having some success printing via Googles Cloud Print service. But wondering if anyone has information regarding the capabilities parameter when submitting a job to print and some pointers in how to create and work this format which I believe is ppd.
We have been able to get the capabilities of the printer via using the method http://www.google.com/cloudprint/printer which returns all the values for our printer. The problem is we don't quite understand what we are meant to do with this in order to define the capability options we would like to print with. This would include options for the copies of pages printed, paper type and print quality. An example of the capabilities information we can receive is like this :
{
"name": "copies",
"displayName": "Copies",
"type": "ParameterDef"
}
{
"UIType": "PickOne",
"name": "HPEconoMode",
"displayName": "EconoMode",
"type": "Feature",
"options": [
{
"ppd:value": "\"\"",
"default": true,
"name": "PrinterDefault",
"displayName": "Printer's Current Setting"
},
{
"ppd:value": "\u003c\u003c/EconoMode true\u003e\u003e setpagedevice",
"name": "True",
"displayName": "Save Toner"
},
{
"ppd:value": "\u003c\u003c/EconoMode false\u003e\u003e setpagedevice",
"name": "False",
"displayName": "Highest Quality"
}
]
}
The GCP documentation is badly lacking in this regard. Anyway, I've managed to find that the correct parameter to send printer settings is ticket, not capabilities. The first part of the parameters corresponds to the basic settings from the print dialog and they are quite self-explanatory and the values are easy to change. The vendor_ticket_item array is a bit more complicated. It contains id/value pairs described by the printer capabilities. The id will contain the name of the parameter from the capabilities and the value will contain the name of one of the records in the parameter options, or a numeric value etc, as described in the capabilities.
For mode details please take a look at my full solution.
{
"version":"1.0",
"print":{
"color":{"vendor_id":"psk:Color","type":0},
"duplex":{"type":0},
"page_orientation":{"type":1},
"copies":{"copies":1},
"dpi":{"horizontal_dpi":600,"vertical_dpi":600},
"media_size":{"width_microns":148000,"height_microns":210000,"is_continuous_feed":false},
"collate":{"collate":true}
,
"vendor_ticket_item":[
//Printer specific settings here, from the capabilities:
{"id":"psk:JobInputBin","value":"ns0000:Tray3"},
{"id":"psk:PageICMRenderingIntent","value":"psk:Photographs"},
{"id":"psk:PageMediaType","value":"ns0000:Auto"},
{"id":"psk:JobOutputBin","value":"ns0000:Auto"},
//etc.
]
}
}