Skip to content

Day 55-57 Example - write_post() #49

Closed
@rfbernstein

Description

@rfbernstein

Within my write_post() implementation, the call resp.json() in the print() returns a list of the previous (in my case) three published items but not the new post that the write_post() was to create. I ran this the original project code using both uplink version 0.4.0 and uplink version 0.9.1 with the same results. I have double checked the source code with the code posted in github. The console output is provided below. Any assistance is appreciated.

C:\Users\rbern\PycharmProjects\ScrapyPractice2\venv\Scripts\python.exe C:\Users\rbern\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\201.6668.115\plugins\python\helpers\pydev\pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 52869 --file C:/Users/rbern/Desktop/course100days/days/55-57-uplink/demo/program.py
pydev debugger: process 8784 is connecting

Connected to pydev debugger (build 201.6668.115)
What would you like to do next?
[w]rite a post or [r]ead them?

  1. [1,231 views] Easy Breezy Python HTTP Clients
  2. [10 views] Introducing Requests for Python
  3. [100 views] PyCharm, the Best IDE for Python

Which number to view? Details for selected_post: c7081102-e2c9-41ec-8b79-adc1f3469d91
Title: Easy Breezy Python HTTP Clients
Written: 2017-02-14
Content: So maybe you've heard about Requests...

What would you like to do next?
[w]rite a post or [r]ead them?Title: Body contents: view count (int):
Traceback (most recent call last):
File "C:\Users\rbern\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\201.6668.115\plugins\python\helpers\pydev\pydevd.py", line 1438, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Users\rbern\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\201.6668.115\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/rbern/Desktop/course100days/days/55-57-uplink/demo/program.py", line 58, in
main()
File "C:/Users/rbern/Desktop/course100days/days/55-57-uplink/demo/program.py", line 12, in main
write_post()
File "C:/Users/rbern/Desktop/course100days/days/55-57-uplink/demo/program.py", line 53, in write_post
print("Created new post successfully: {}".format(resp.json().get('id')))
AttributeError: 'list' object has no attribute 'get'

Process finished with exit code -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions