I'm implementing an integration with Google Spreadsheets API and PHP. I'm using the library suggested by google.
I need to have many sheets (pages) in the same file. So far, I found that I can create new pages using something like this:
$body = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array(
'requests' => array('addSheet' => array('properties' => array('title' => $title )))));
$result = $service->spreadsheets->batchUpdate(SHEET_ID,$body);
But how can I choose when to write on one sheet(page) or the other? Is there some method that allows me to choose the sheet by it's label?
Hope you can help me.
Rather than specifying a sheet alone, based on the Basic Writing sample, you can write on a specific range on a specific sheet using a PUT method:
PUT https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId/values/Sheet1!A1:D5?valueInputOption=USER_ENTERED
This spreadsheets.values.update request will write the values on the cells from A1 to D5 on Sheet1. Note that the ValueInputOption query parameter is required and determines if the values written will be parsed (for example, whether or not a string is converted into a date).
The request body would then look like this:
{
"range": "Sheet1!A1:D5",
"majorDimension": "ROWS",
"values": [
["Item", "Cost", "Stocked", "Ship Date"],
["Wheel", "$20.50", "4", "3/1/2016"],
["Door", "$15", "2", "3/15/2016"],
["Engine", "$100", "1", "30/20/2016"],
["Totals", "=SUM(B2:B4)", "=SUM(C2:C4)", "=MAX(D2:D4)"]
],
}
Related
I am working on a Zapier integration for an online form builder. Each unique form for our users has lots of long, auto-generated field names.
We have a trigger called “New form entries”, which polls our server for form entries, and comes back like this:
[
{
"id": "6209aee326baa600224d822c",
"email_907058157108782": "test#test.com",
"phone_589083232390193": "12345",
},
{
"id": "61fd629f19408200225e1893",
"email_907058157108782": "test#test2.com",
"phone_589083232390193": "54321",
},
]
However, this results in end users seeing these really long, gross field names in the Zapier interface:
My question: how do I get Zapier to display friendly labels to the user, whilst using the unique field IDs behind the scenes?
I’m thinking of returning something like the following (each object represents a form entry, , but I need to know how to actually use “friendlyFieldName” and “value” in Zapier!-
[
{
// the id for the entry
"id": "62179ec5ab9daa0022df7d1d",
// the id for the first field entry
"text_576692390099896": {
// a friendly name and value for zapier
"friendlyFieldName": "What is your favourite colour?",
"value": "Blue"
}
}
]
Thank you :)
You can define output fields labels in outputFields. Here are the reference document that you can follow: Output Fields
How do I connect my database to API.AI
Making every sentence into INTENT and creating entities for each doesn't seem to be a good idea? So what is the best possible way to go about?
As far as I know it is not possible yet, but you can switch to row mode and past your entities inCVS or JSON format OR import a JSON/CSV file containing all your entities.
The file should look like below (JSON format):
[
{
"value": "val1",
"synonyms": [
"syn1",
"syn2"
]
},
{
"value": "val2",
"synonyms": [
"syn21",
"syn22"
]
},
]
So you can image of writing a small job that reads entities from you DB and make a JSON/CSV file according the wanted format.
Once the job done, this process may dramatically facilitate the creation of your entities on api.ai.
If you use a webhook for an intent, you can pass params to your endpoint where you can do all the queries to your db
I did a demo where I was querying news (cheating as I was getting it from the web, but I could plug a DB).
The was getting requests such as:
"What are the latest news about France"
latest and France would be params that I send through to the webhook endpoint.
You would get the following JSON sent your endpoint by API.AI
"result": {
"source": "agent",
"resolvedQuery": "latest news about France",
"action": "show.news",
"actionIncomplete": false,
"parameters": {
"adjective": "latest",
"subject": "France"
}
Then you can query all the news for France and order them by latest
In my understanding the idea is to create entities that are "placeholders" for the values you need to query.
Then you teach the AI with few examples by tagging in the request what did the person ask. Let say someone asks:
"what is the oldest news about France?"
The AI may not know what is oldest thus you tell it is is an adjective and from now on you can get oldest as a param
I am new to Docusign api and I am trying to post values from my form into a template. To be honest, I am not sure if I even created the custom fields properly or if there is some special way to set them into the form other than just creating a text field with a name.
I have read through the docs and recipes and about a dozen or more stack posts.
I am using rails and my fields post just fine but it's my tabs that do not. I read somewhere that I am supposed to use tabs and not custom_fields. Not sure if that's totally correct but that's how I've interpreted it.
Here is my current code:
body: {
"emailSubject": "DocuSign API call - Request Signature - Boom",
"templateId": "e1d5bce1-9757-4ffe-881b-054aa9139f2f",
"templateRoles": [{
"email": "#{renter.email}",
"name": "#{renter.background.legal_name}",
"roleName": "Lessee"
},{
"email": "#{#manager.email}",
"name": "#{#manager.name}",
"roleName": "Lessor",
"tabs": {
"texttabs": [{
"tabLabel": "Rent",
"value": "#{#lease.rent}"
},{
"tabLabel": "Address",
"value": "987 apple lane"
}]
}
}],
"status": "sent"
}.to_json
baseUrl that I am sending to:
"https://demo.docusign.net/restapi/v2/accounts/my_id/envelopes"
In your texttabs section, you should be passing in the following parameters at a minimum per tab: tablabel & value.
tablabel is the name of the tab that you have defined on the template. So from what I can tell, you have a text box on your template called Address. So you should put "tablabel":"Address".
value is what you would like to pre-populate in the tab. Looks like you have that correct.
You do not want to use tabID as that is not a valid parameter in this flow. The API documentation details what parameters you can use: https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Tabs/Text%20Tab.htm?Highlight=data%20tab
I also see an extraneous parameter of "Rent" under templateRoles section. That value will be ignored since it is not a valid parameter.
Turns out the problem was not with the code but with the setup within docusign. Make sure that you are setting up your tabs correctly and if you want to replicate a field multiple times make sure that they all share the same exact name.
Since JIRA API only allows to make a search request with a max result of 1000 issues, I need to know if there is a way to get the total number of issues a project so I can iterate through all thousands of issues.
IRestResponse responseIssues = client.Execute(new RestRequest("search?jql=project=" + "\"DATPROJECT\"" + "&maxResults=5000&fields=assignee,summary,timetracking,resolutiondate,resolution,worklog", Method.GET));
I am currently doing like the code above but I only get 1000 results and not 5000 that I need. I know that I can use the filter "startAt" to iterate over all results but I don't know how many issues exist.
Any ideas?
The search rest point returns total number of issues for a given JQL search. Example result from documentation
{
"expand": "names,schema",
"startAt": 0,
"maxResults": 50,
"total": 1,
"issues": [
{
"expand": "",
"id": "10001",
"self": "http://www.example.com/jira/rest/api/2/issue/10001",
"key": "HSP-1"
}
]
}
This "total":1 value is the one you're looking for.
Hey from rest Api I don't find any rest where you can get all issue.but if you want all issue you can get it from java side. if you need total number of issues use
long getIssueCountForProject (Long projectId)
and if you want all issues and want to iterate it use
Collection<Long> getIssueIdsForProject (Long projectId)
please refer atlassian documentation for all this method.
Thank you.
You can use maxResults=0 to get only descriptive data omitting the actual results.
For example, if we want to know the amount of open issues for the currently logged in user:
rest/api/2/search?jql=project=SP+AND+statusCategory!=3+AND+assignee+in+(currentUser())&maxResults=0
The result:
{
"startAt": "0",
"maxResults": "0",
"total": "68",
"issues": [
]
}
The "total" field here is just what we need.
I am working on integration with our university's SIS system and am stumbling a bit with the documentation related to creating and updating sections. http://docs.valence.desire2learn.com/res/enroll.html#Section.SectionData
I can use the route PUT /d2l/api/lp/(version)/(orgUnitId)/sections/ to create a default section named Section 1 with section code sec1 however when I try to update it or add an additional section with the routes: PUT /d2l/api/lp/(version)/(orgUnitId)/sections/(sectionId) (with the sectionId retrieved from my previous PUT) or POST /d2l/api/lp/(version)/(orgUnitId)/sections/
I am using the following block for my json data:
{
"Name": "Section 1d",
"Code": "Dan 101",
"Description": {
"Text": "",
"Html": ""
}
}
What am I missing in the syntax?
Thank You
The way you use the Valence Learning Framework API to create sections for course offerings is idiosyncratic. Assume you start with a blank course, that has no descendant org units (no sections, no groups, nothing):
GET /d2l/api/lp/1.3/orgstructure/113459
> {"Name": "Extensibility 106",
"Identifier": "113459",
"Type": {"Name": "Course Offering",
"Code": "Course Offering",
"Id": 3},
"Code": "EXT-106"}
GET /d2l/api/lp/1.3/orgstructure/113459/children
> []
Initialize course with section properties. The first thing you have to do is define the section properties for the course offering: what kind of sections do you want to create under the course offering? To create the section properties for the course offering, you use a SectionPropertyData block; here's one that says "I want this course to have 10 sections and to auto-enroll the students, randomly, into these sections" (EnrollmentStyle 2 corresponds to NumberOfSectionsAutoEnrollment):
{"AutoEnroll": true,
"EnrollmentQuantity": 10,
"EnrollmentStyle": 2,
"RandomizeEnrollments": true}
Now, to initialize the course with these settings, and have the first default section(s) created, we PUT that block to this route:
PUT /d2l/api/lp/1.3/113459/sections/
> [{"SectionId":113460,
"Name":"Section 1",
"Description":{"Text":"","Html":""},
"Enrollments":[]},
...
{"SectionId":113469,
"Name":"Section 10",
"Description":{"Text":"","Html":""},
"Enrollments":[]}
]
Notice that with this call, we've now created 10 sections as children of this course offering, and the back-end service has automatically generated names (and codes) for them.
Add a new section after the fact. Now suppose we want to add an eleventh section to this course. First, we need to use a SectionData block for the new section's properties:
{"Name": "Section 11",
"Code": "Sec11",
"Description": {"Content": "New Section Descr.", "Type": "Text} }
(Note: When you form this block to create the new section you have to use a RichTextInput type structure for the Description property. When you get the properties for a section back from the service, it writes the description using the RichText property instead. This is a common sticky point for devs new to the framework)
Then, you POST that block to this route:
POST /d2l/api/lp/1.3/113459/sections/
> {"SectionId":113470,
"Name":"Section 11",
"Description":{"Text":"Description","Html":""},
"Enrollments":[]}
You'll get back the properties for the newly created section.
Summary. So, "why PUT and then POST"? Yes, it is a bit confusing, but think of it this way:
The first use, of PUT, is to update the "section properties" attribute for a course offering (as a consequence, when a course offering's section properties are initially defined, as a side effect, the back-end creates the section org units needed to go along with those new settings).
The second use, of POST, is to create a new org unit (a new section), and assign it to the course offering.
It looks like your routes and your request are okay. Only one small change with the route. You need to use the RichTextInput field that is described in the documentation D2L Conventions
Basically instead of:
"Description": {
"Text": "",
"Html": ""
}
You need:
"Description": {
"Content": "",
"Type": "" (Either Text or Html)
}