Payload structure in the taskqueue

36 views
Skip to first unread message

JohnGB

unread,
Mar 2, 2016, 5:22:27 PM3/2/16
to Google App Engine
I'm using Go, and I'm trying to place a task on the taskqueue which has some JSON encoded content in the body.  However, I seem to be getting 301 responses, and it seems to be related to the Task.Payload.

The code that I'm using is structurally as the code below, with `am` being a struct with working JSON tags:


func QueueAdminMessage(ctx context.Context, am adminMessage) error {

// Encode the admin message.
rawMsg, err := json.Marshal(am)
if err != nil {
return err
}

task := &taskqueue.Task{
Path:    endpoints.SendAdminMessage,
Payload: rawMsg,
Method:  "POST",
}

newTask, err := taskqueue.Add(ctx, task, "admin-messaging")
if err != nil {
return err
}
log.Debugf(ctx, "New Task:\n  Path: %s\n  Payload:%s", newTask.Path, string(newTask.Payload))
return nil
}

This seems to add a task to the taskqueue, but the task constantly fails (with a 301 response).  My guess is that I'm not setting the Payload up correctly, but I can't find very much on how to specify a body content with the payload.  The documentation states (in reference to the Payload):

    // Payload is the data for the task.
   
// This will be delivered as the HTTP request body.
   
// It is only used when Method is POST, PUT or PULL.
   
// url.Values' Encode method may be used to generate this for POST requests.

It says that the url.Values Encode method *may* be used, but not that it *must* be used.

JohnGB

unread,
Mar 3, 2016, 10:52:11 AM3/3/16
to Google App Engine
It seems that the payload was not the problem.  The problem is that the request from the taskqueue comes in as an unsecured connection (HTTP instead of HTTPS), which was being rejected by our app.
Reply all
Reply to author
Forward
0 new messages