Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use requestBody instead of resource #1149

Merged
merged 3 commits into from May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -266,12 +266,12 @@ See the [Options section][options] for more information.

### Specifying request body

The body of the request is specified in the `resource` parameter object of the request. The resource/body is specified as a JavaScript object with key/value pairs. For example, this sample creates a watcher that posts notifications to a Google Cloud Pub/Sub topic when emails are sent to a gmail account:
The body of the request is specified in the `requestBody` parameter object of the request. The body is specified as a JavaScript object with key/value pairs. For example, this sample creates a watcher that posts notifications to a Google Cloud Pub/Sub topic when emails are sent to a gmail account:

```js
const res = await gmail.users.watch({
userId: 'me',
resource: {
requestBody: {
// Replace with `projects/${PROJECT_ID}/topics/${TOPIC_NAME}`
topicName: `projects/el-gato/topics/gmail`
}
Expand All @@ -280,7 +280,7 @@ console.log(res.data);
```

### Media uploads
This client supports multipart media uploads. The resource parameters are specified in the `resource` parameter object, and the media itself is specified in the `media.body` parameter with mime-type specified in `media.mimeType`.
This client supports multipart media uploads. The resource parameters are specified in the `requestBody` parameter object, and the media itself is specified in the `media.body` parameter with mime-type specified in `media.mimeType`.

This example uploads a plain text file to Google Drive with the title "Test" and contents "Hello World".

Expand All @@ -291,7 +291,7 @@ const drive = google.drive({
});

const res = await drive.files.create({
resource: {
requestBody: {
name: 'Test',
mimeType: 'text/plain'
},
Expand All @@ -314,7 +314,7 @@ const drive = google.drive({

async function main() {
const res = await drive.files.create({
resource: {
requestBody: {
name: 'testimage.png',
mimeType: 'image/png'
},
Expand Down Expand Up @@ -487,6 +487,7 @@ We love contributions! Before submitting a Pull Request, it's always good to sta
* Ask your development related questions on [Stackoverflow][stackoverflow].
* If you've found an bug/issue, please [file it on GitHub][bugs].


[snyk-image]: https://snyk.io/test/github/google/google-api-nodejs-client/badge.svg
[snyk-url]: https://snyk.io/test/github/google/google-api-nodejs-client
[david-image]: https://david-dm.org/google/google-api-nodejs-client.svg
Expand Down