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

Problem Creating a User Via API (Setting Token) #14

Open
craiglathrop218 opened this issue Jun 1, 2016 · 3 comments
Open

Problem Creating a User Via API (Setting Token) #14

craiglathrop218 opened this issue Jun 1, 2016 · 3 comments

Comments

@craiglathrop218
Copy link

My developer found an issue with the API when he was trying to create a new user. Here is his explanation below:

In the Api.prototype.request function in file plugins/request.js, util._extend method is used like this: util._extend(options, this.httpOptions);
but this only makes shallow copy of an object - meaning that this.httpOptions.headers is copied as a reference and later in the method there are lines that put options.headers['Content-Length'] = params.length;

So that last line actually modifies this.httpOptions.headers
and for later call to Api.prototype.request the previous headers are used

I had a login as a POST which were setting the headers and then I had just after that PUT which did not set the headers but because POST set the headers then PUT got the previous request headers

The fix was to replace util._extend with a function that makes deep copies of the objects and not shallow copies
installed deep-extend module that provided a short path to make deep copies of objects
util._extend(options, this.httpOptions); went to deepExtend(options, this.httpOptions);

@bhovhannes
Copy link
Member

@craiglathrop218, if you've already done a fix, can you come back with pull request? I'll be happy to merge it if all tests will pass :)

@craiglathrop218
Copy link
Author

We are actually working in TypeScript and have copied the API code into our program rather than using the package. I haven't had a chance to review the code where the fix was implemented yet. Once I have reviewed it I will try to fix it up and provide it as a pull request.

@bhovhannes
Copy link
Member

@craiglathrop218, please try workfront-api v2.0.1 and let us know if the issue still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants