upwork / python-upwork

Python bindings for Upwork API
Apache License 2.0
163 stars 55 forks source link

Milestones Order Not Correct #19

Closed gobid closed 7 years ago

gobid commented 8 years ago

I am using the upwork api to make an offer. I notice the milestones are not getting ordered properly:

>>> milestones

[{'due_date': '08-15-2017', 'deposit_amount': 60, 'milestone_description': '1. Basic English Exam (mcq), Grammar Exam (mcq), Early Math Exam (mcq), and Arithmetic Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-16-2017', 'deposit_amount': 40, 'milestone_description': '2. Algebra Exam (mcq) and Geometry Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-17-2017', 'deposit_amount': 80, 'milestone_description': '3. Introductory CS Exam (mcq), Command Line Exam (mcq), Source Control Exam (mcq), and Internet Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-18-2017', 'deposit_amount': 30, 'milestone_description': '4. English Exam (mcq) and Idioms exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-19-2017', 'deposit_amount': 60, 'milestone_description': '5. Python Exam (mcq) and SQL Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-20-2017', 'deposit_amount': 45, 'milestone_description': '6. HTML/CSS Exam (mcq) and Javascript Exam (mcq) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-21-2017', 'deposit_amount': 100, 'milestone_description': '7. Django Exam (mcq, includes autograded coding sample) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-22-2017', 'deposit_amount': 75, 'milestone_description': '8. AngularJS Exam (mcq, includes autograded coding sample) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-23-2017', 'deposit_amount': 50, 'milestone_description': '9. Worker Scraper Exam (mcq, includes autograded coding sample) on goo.gl/btyoOM (moodle)'}, {'due_date': '08-24-2017', 'deposit_amount': 50, 'milestone_description': '10. Wordpress Exam (mcq) on goo.gl/btyoOM (moodle)'}]

>>> 

>>> 

>>> client.offers.send_client_offer('Congratulations, you have been offered the job WEBDEVELOPER at Learning Dollars Inc. ' + datetime.strftime(datetime.now(), '%m-%d-%Y'), 'fixed-price', TOTALPRICE, 'Please accept this job to get started at Learning Dollars Inc.', contractor_username='dasugovinda', context=CONTEXT['WEBDEVELOPER'], milestones=milestones, close_on_accept=0)

PRODUCES the attached file

Please let me know the solution.

screen shot 2016-08-15 at 8 21 22 pm

gobid commented 8 years ago

Then I contacted API support and they said:

Hello,

we are sorry, but there is not enough data in your request for doing detailed investigation. Could you please provide us the following information:

To which I responded:

# this is done after: 
client = upwork.Client(UPWORK_KEY, UPWORK_SECRET, oauth_access_token=ACCESS_TOKEN, oauth_access_token_secret=ACCESS_TOKEN_SECRET)
UPWORK_KEY = 'UPWORK_KEY'
UPWORK_SECRET = 'UPWORK_SECRET'
UPWORK_VERIFIER = 'UPWORK_VERIFIER'
ACCESS_TOKEN = 'ACCESS_TOKEN'
ACCESS_TOKEN_SECRET = 'ACCESS_TOKEN_SECRET'
Traceback (most recent call last):

  File "<console>", line 1, in <module>

  File "/Users/govindadasu/Desktop/learningdollars/00-ldrest/venv/lib/python2.7/site-packages/upwork/routers/offers.py", line 186, in send_client_offer

    return self.post(url, data)

  File "/Users/govindadasu/Desktop/learningdollars/00-ldrest/venv/lib/python2.7/site-packages/upwork/namespaces.py", line 37, in post

    return self.client.post(self.full_url(url), data)

  File "/Users/govindadasu/Desktop/learningdollars/00-ldrest/venv/lib/python2.7/site-packages/upwork/client.py", line 176, in post

    return self.read(url, data, method='POST', fmt=self.fmt)

  File "/Users/govindadasu/Desktop/learningdollars/00-ldrest/venv/lib/python2.7/site-packages/upwork/client.py", line 290, in read

    raise_http_error(url, response)

  File "/Users/govindadasu/Desktop/learningdollars/00-ldrest/venv/lib/python2.7/site-packages/upwork/http.py", line 45, in raise_http_error

    headers, None)

HTTP403ForbiddenError: HTTP Error 403: Code 403: Duplicate timestamp/nonce combination, possible replay attack. Request rejected.

Note, even though I get a 403, the offer is still made every time.

see above 403 To which they responded:

From the provided information, it seems you are running two requests one by another, therefore, 2nd request fails with 403, because it uses duplicated data. It's either an issue in your script, or you don't use proper timeouts for your requests.

We also didn't found the following info:

What is also confusing - Send offer API returns only an ID of a new offer. Could you please specify which API you used to get milestones, i.e. provide the same detailed information?

To which I responded:

I am using the python driver which is displayed on your developers website. See attached. I do not know the HTTP level information as I'm using your python driver. Could you please provide me help at the python driver level.

screen shot 2016-08-16 at 9 22 28 pm

mnovozhylov commented 8 years ago

@govindad , response from the server is returned by the library 'as is', i.e. it's not sorted on library's side. Please, contact apisupport to clarify all the details related to your particular request.

gobid commented 8 years ago

I am in conversation with API support now. I will post the answer when they provide me the solution.

mnovozhylov commented 8 years ago

@govindad , please, let's not confuse other consumers - api responses have nothing to do with the functionality of the library.

gobid commented 8 years ago

It's not even the response that is concerning. It's the fact that the API doesn't order the milestones correctly. I do not know yet whether this is an issue with the API or the driver, but I am finding out.

Try this example https://developers.upwork.com/?lang=python#contracts-and-offers_get-client-offer with an additional third milestone called "description 3" and you'll see exactly what the issue is ... they don't get ordered properly.

I have not worked with the API directly or with any other driver, so I have no idea whether this is a driver issue or an API issue.

mnovozhylov commented 8 years ago

Finally, apisupport received the needed details fully. Thus, the concern is not about response or display on GUI, but about 'milestone' parameter in Send Offer API, i.e. possible mix of orders in line https://github.com/upwork/python-upwork/blob/master/upwork/routers/offers.py#L179

We will check the theory as soon as possible.

gobid commented 8 years ago

great to hear you are in communication with them

gobid commented 8 years ago

hi @mnovozhylov do you have any update on this issue?

mnovozhylov commented 7 years ago

The issue should be already fixed on backend side. python-upwork shows 'milestones[0][deposit_amount]': '101', 'milestones[0][due_date]': '03-15-2015', 'milestones[0][milestone_description]': 'description 1', 'milestones[1][deposit_amount]': '102', 'milestones[1][due_date]': '03-18-2015', 'milestones[1][milestone_description]': 'description 2', 'milestones[2][deposit_amount]': '103', 'milestones[2][due_date]': '05-28-2016', 'milestones[2][milestone_description]': 'description 3',