Skip to content

Commit

Permalink
fix(issue-640): adding headers in task request samples (#642)
Browse files Browse the repository at this point in the history
* fix: adding headers in task request

refactor: updating readme with same fix

* refactor: lint fixes

* fix: switch content-type expected

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Averi Kitsch <akitsch@google.com>
  • Loading branch information
3 people authored Sep 15, 2022
1 parent 944fbbf commit 92d6a3c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cloud-tasks/createHttpTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ function main(

const task = {
httpRequest: {
headers: {
'Content-Type': 'text/plain',
},
httpMethod: 'POST',
url,
},
Expand Down
3 changes: 3 additions & 0 deletions cloud-tasks/createHttpTaskWithToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ function main(

const task = {
httpRequest: {
headers: {
'Content-Type': 'text/plain',
},
httpMethod: 'POST',
url,
oidcToken: {
Expand Down
5 changes: 5 additions & 0 deletions cloud-tasks/createTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function main(

const task = {
appEngineHttpRequest: {
headers: {
'Content-Type': 'text/plain',
},
httpMethod: 'POST',
relativeUri: '/log_payload',
},
Expand All @@ -66,12 +69,14 @@ function main(

console.log('Sending task:');
console.log(task);

// Send create task request.
const request = {parent: parent, task: task};
const [response] = await client.createTask(request);
const name = response.name;
console.log(`Created task ${name}`);
}

createTask();
// [END cloud_tasks_appengine_create_task]
}
Expand Down

0 comments on commit 92d6a3c

Please sign in to comment.