DocuSign API Replace template document but keep fields - php

I want to use the existing fields from a server template over another document.
At first I tried attaching the document at the same level as inline/server.
If I have the signer defined it gives me a 400 error, if I leave it off (did by accident) it completely wipes out the fields and shows the attached document.
Second I tried attaching the document to the inline template but that results in the attached document not appearing, it just operates like normal.
update
After adding additional debugging and research I now know that attaching it to the inline template was incorrect. After adding debug to read the 400 response I am getting this error:
"The DocumentId specified in the tab element does not refer to a document in this envelope. Tab refers to DocumentId 32475214 which is not present."
DocumentId is being set to 1 which is apparently wrong.
Which led me to this question on SO. In which a comment mentions that the ID kicked back from the 400 should be used.
After I hard coded this ID I see the replacement operation is a success!
However I now need to find a way find and to plug that value in programatically.
Detail
I am using the DocuSign php sdk to help me build the data structure and access the api.

Use the listTemplateDocuments API to retrieve the documentId for the template.
The documentId retrieved in the above step should be used in the CompositeTemplate of CreateEnvelope request
{
"emailSubject": "Tabs should remain from the Server Template",
"status": "sent",
"compositeTemplates": [
{
"document": {
"documentId": "<document Id>", //Use the documentId retrieved using the listTemplateDocuments api
"name": "Replaced Document",
"fileExtension": "txt",
"documentBase64": "RG9jIFRXTyBUV08gVFdP"
},
"serverTemplates": [
{
"sequence": "1",
"templateId": "<Server Template Id Here>"
}
]
}
]
}

Related

How to tag users with #mention/#tag in a line group using line bot webhook requests

I cannot find anything in line message API that shows how to tag or mention users in a group that the bot is part of.
C98a77173e4622xxxxxxxxxxxxxxxx is the group ID to which I need to send the message to and U5a4640d93cxxxxxxxxx is the user I am trying to tag.
I tried something like this:
$data = '{
"to": "C98a77173e4622xxxxxxxxxxxxxxxx" ,
"messages": [
{
"type": "text",
"text": "#{U5a4640d93cxxxxxxxxx}"
}
]
}';
This did not work though. I tried all the possible combinations I could think of as the text content but everything just gets sent as it is and not getting converted to mentions or tags. I have seen other bots doing this and more actions like removing users from groups, adding users to groups, cancelling invitations and a lot more but none of these message types are mentioned in line Message API. Am I missing something?
There is not this api now.
You can't tag someone by using line-api.

Any way in OneNote API to extract link to another OneNote page?

If we have a link to another OneNote page in the HTML content:
<a href="onenote:SectionB.one#Note1&section-id={<section-id>}&page-id={<page-id>}&end&base-path=https://<path>"
... before I write a parsing routine to extract that link, I thought I'd ask if I'd overlooked anything in the OneNote API to make this easier.
===========================================================================
[EDIT] Well, I've written my routine to extract the page-id of the linked note, but that page-id turns out to be quite different from the page-id that's returned as a property (id) of the linked note itself - and it doesn't work :(
Here's an example:
(1) page-id extracted from link: A8CECE6F-6AD8-4680-9773-6C01E96C91D0
(2) page-id as property of note:
0-5f49903893f048d0a3b1893ef004411f!1-240BD74C83900C17!124435
Vastly different, as you see. Accessing the page content via:
../pages/{page-id}/content
... for (1) returns nothing
... for (2) returns the full page content.
(The section-ids returned by both methods are also entirely different.)
So, how can I extract from the link a page-id that works?
Unfortunately, the OneNote API currently does not support identifying links to other OneNote pages in page content. Links in OneNote can be links to anything: websites, other OneNote pages/sections/notebooks, network shares...
The API does support getting links to pages by using
GET ~/pages
GET ~/sections/id/pages
The page metadata model contains a links object with the clientUrl and the webUrl.
Editing after your question update:
You're right - the id in the link does not correspond to the id of the OneNote API. You can however compare the id in the link with the id in the OneNoteClientUrl exposed in the API. Here's an example of the response of a
GET ~/sections/id/pages
GET ~/pages
{
"title": "Created from WAC",
"createdByAppId": "",
"links": {
"oneNoteClientUrl": {
"href": "onenote:https://d.docs.live.net/29056cf89bb2d216/Documents/TestingNotification/Harrie%27s%20Section.one#Created%20from%20WAC&section-id=49b630fa-26cd-43fa-9c45-5c62d547ee3d&page-id=a60de930-0b03-4527-bf54-09f3b61d8838&end"
},
"oneNoteWebUrl": {
"href": "https://onedrive.live.com/redir.aspx?cid=29056cf89bb2d216&page=edit&resid=29056CF89BB2D216!156&parId=29056CF89BB2D216!105&wd=target%28Harrie%27s%20Section.one%7C49b630fa-26cd-43fa-9c45-5c62d547ee3d%2FCreated%20from%20WAC%7Ca60de930-0b03-4527-bf54-09f3b61d8838%2F%29"
}
},
"contentUrl": "https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162/content",
"thumbnailUrl": "https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162/thumbnail",
"lastModifiedTime": "2016-03-28T21:36:22Z",
"id": "0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162",
"self": "https://www.onenote.com/api/v1.0/me/notes/pages/0-a50842a9873945379f3d891a7420aa39!14-29056CF89BB2D216!162",
"createdTime": "2016-03-24T20:38:16Z",
"parentSection#odata.context": "https://www.onenote.com/api/v1.0/$metadata#me/notes/pages('0-a50842a9873945379f3d891a7420aa39%2114-29056CF89BB2D216%21162')/parentSection(id,name,self)/$entity",
"parentSection": {
"id": "0-29056CF89BB2D216!162",
"name": "Harrie's Section",
"self": "https://www.onenote.com/api/v1.0/me/notes/sections/0-29056CF89BB2D216!162"
}
}
You can also filter server side (if you want to save yourself from paging and regex's ;) ) for id's in the links by using:
GET ~/pages?$filter=contains(links/oneNoteClientUrl/href,'a60de930-0b03-4527-bf54-09f3b61d8838')

How to get form fields in Facebook Lead Ads API?

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...

Finding all pages containing images in Wikimedia Commons category via API

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.

Bulk inserting documents into couchbase database with php - how to?

I am experimenting actually a little bit with couchbase server.
I have tried to read a mysql database table, build a document from each data row and then inserting the document with an id which I generate with
uniqid('table_name');
via cUrl, method is POST.
This so far works pretty good, until the script has inserted roundabout 7050 documents. Then an exception is thrown -> "No buffer space".
Until now I was not able to fix this, so I decided to collect i.e. 50 rows of data build a json_encode(d) string and POST it again via cUrl.
This worked so far if I don't set the id - but I can't figure out how to set the id of the inserted documents.
Actually I try to send my documents in a format like this:
{"docs": {
"_id": {
"geodata_de_54476f7e6adc57.14196038": {
"table": "geodata_de",
"country": "DE",
"postal_code": "01945",
"place_name": "Lindenau",
"state_name": "Brandenburg",
"state_code": "BB",
"province_name": "",
"province_code": "00",
"community_name": "Oberspreewald-Lausitz",
"community_code": "12066",
"lat": "51.4",
"lng": "13.7333",
"Xco": "3861.1",
"Yco": "943.614",
"Zco": "4979.07"
}
}, ...
}
}
but this just inserts ONE document with the above object.
Maybe there is someone here who can point me the right direction.
I would use the Couchbase PHP SDK to insert these documents instead of using curl. http://docs.couchbase.com/developer/php-2.0/storing.html
Also for CB, you do not have to set the ID in the document itself. it depends. I might take a look at instead using the ID you have in your example ("geodata_de_54476f7e6adc57.14196038") and put it as the key for the object in Couchbase. Then you do not necessarily need the _id. The key in Couchbase can be up to 250 bytes of data and you can make it meaningful to your application so you can do lookup by key extremely fast.
Another option is, if you wrote your docs to the filesystem, you could also use cbdocloader utility which is specifically for bulk loading docs. If you are on linux it is in /opt/couchbase/bin/tools/cbdocloader.

Categories