Skip to content
This repository was archived by the owner on Dec 27, 2018. It is now read-only.
This repository was archived by the owner on Dec 27, 2018. It is now read-only.

request_type DELETE #9

Closed
Closed

Description

@yangyixizg

When I use the request_type "DELETE", I got ValueError: No JSON object could be decoded.

My temporary solution: Insert if-brauch before else in the method _service_request

def _service_request(...):
...
if request_type == "DELETE":
return
else:
return response.content if raw else json.loads(response.text)

Activity

  1. rpcope1 commented on Oct 21, 2015

    @rpcope1
    Owner

    Can you dump what response.text has in it when DELETE is called?

  2. rpcope1 commented on Oct 21, 2015

    @rpcope1
    Owner

    Also, can you give me what the traceback on that was, as well as the version of Python you are using?

  3. yangyixizg commented on Oct 22, 2015

    @yangyixizg
    Author

    I am using Python 2.7.
    I got 4 outputs when I check response.text before if-branch for DELETE and 1 output of response.text inside of if-branch, for example:

    • case 1:
    print "response.text:"
    print response.text
    if request_type == "DELETE":
      return
    else:
      return response.content if raw else json.loads(response.text)
    response.text:
    {"id":"1998892","type":"page","status":"current","title":"Page Temp 1","space":{"id":753665,"key":"MYS","name":"My Space 1 v2","type":"global","_links":{"self":"http://localhost:8090/rest/api/space/MY
    S"},"_expandable":{"icon":"","description":"","homepage":"/rest/api/content/524292"}},"history":{"latest":true,"createdBy":{"type":"known","profilePicture":{"path":"/s/en_GB/5994/3a465f7321af83b92e8f7
    149d515f72cee083e87.1/_/images/icons/profilepics/default.png","width":48,"height":48,"isDefault":true},"username":"yyang82","displayName":"Yixi Yang","userKey":"8a5946ab507f2c0d01507f2c21d80001"},"cre
    atedDate":"2015-10-22T07:50:03.177+02:00","_links":{"self":"http://localhost:8090/rest/api/content/1998892/history"},"_expandable":{"lastUpdated":"","previousVersion":"","nextVersion":""}},"version":{
    "by":{"type":"known","profilePicture":{"path":"/s/en_GB/5994/3a465f7321af83b92e8f7149d515f72cee083e87.1/_/images/icons/profilepics/default.png","width":48,"height":48,"isDefault":true},"username":"yya
    ng82","displayName":"Yixi Yang","userKey":"8a5946ab507f2c0d01507f2c21d80001"},"when":"2015-10-22T07:50:03.177+02:00","message":"","number":1,"minorEdit":false},"ancestors":[],"container":{"id":753665,
    "key":"MYS","name":"My Space 1 v2","type":"global","_links":{"self":"http://localhost:8090/rest/api/space/MYS"},"_expandable":{"icon":"","description":"","homepage":"/rest/api/content/524292"}},"body"
    :{"storage":{"value":"This is a temporary page.","representation":"storage","_expandable":{"content":"/rest/api/content/1998892"}},"_expandable":{"editor":"","view":"","export_view":"","anonymous_expo
    rt_view":""}},"extensions":{"position":"none"},"_links":{"webui":"/display/MYS/Page+Temp+1","tinyui":"/x/LIAe","collection":"/rest/api/content","base":"http://localhost:8090","context":"","self":"http
    ://localhost:8090/rest/api/content/1998892"},"_expandable":{"metadata":"","operations":"","children":"/rest/api/content/1998892/child","descendants":"/rest/api/content/1998892/descendant"}}
    response.text:
    {"results":[{"id":"1998892","type":"page","status":"current","title":"Page Temp 1","extensions":{"position":"none"},"_links":{"webui":"/display/MYS/Page+Temp+1","tinyui":"/x/LIAe","self":"http://local
    host:8090/rest/api/content/1998892"},"_expandable":{"container":"","metadata":"","operations":"","children":"/rest/api/content/1998892/child","history":"/rest/api/content/1998892/history","ancestors":
    "","body":"","version":"","descendants":"/rest/api/content/1998892/descendant","space":"/rest/api/space/MYS"}}],"start":0,"limit":25,"size":1,"_links":{"self":"http://localhost:8090/rest/api/content?t
    ype=page&title=Page+Temp+1","base":"http://localhost:8090","context":""}}
    response.text:
    
    response.text:
    {"results":[],"start":0,"limit":25,"size":0,"_links":{"self":"http://localhost:8090/rest/api/content?type=page&title=Page+Temp+1","base":"http://localhost:8090","context":""}}
    
    • case 2:
    if request_type == "DELETE":
      print "response.text:"
      print response.text
      return
    else:
      return response.content if raw else json.loads(response.text)
    response.text:
    
    
  4. rpcope1 commented on Oct 22, 2015

    @rpcope1
    Owner

    Interesting. It appears as though when a DELETE call is made, the response
    is essentially empty, which makes reasonable sense. The JSON decoder
    doesn't handle an empty string, hence it triggering an exception. This
    should be a lot easier to filter on than a non-empty, non-JSON response. I
    think I'd like to propose instead of having the conditional filter on the
    request_type (which seems somewhat hokey and artificial), it should filter
    on whether or not the response has any text at all in it. Each API method
    call can return None if no response was received, and the decoded response
    otherwise. I will see if I can't make that change in a branch tomorrow
    morning (it's really late here, currently), and you can give it a go.

    On Thu, Oct 22, 2015 at 12:15 AM, yixiyangh notifications@github.com
    wrote:

    I got 4 outputs when I check response.text before if-branch for DELETE
    and 1 output of response.text inside of if-branch, for example:

    • case 1:

    print "response.text:"print response.textif request_type == "DELETE":
    returnelse:
    return response.content if raw else json.loads(response.text)

    response.text:
    {"id":"1998892","type":"page","status":"current","title":"Page Temp 1","space":{"id":753665,"key":"MYS","name":"My Space 1 v2","type":"global","_links":{"self":"http://localhost:8090/rest/api/space/MY
    S"},"expandable":{"icon":"","description":"","homepage":"/rest/api/content/524292"}},"history":{"latest":true,"createdBy":{"type":"known","profilePicture":{"path":"/s/en_GB/5994/3a465f7321af83b92e8f7
    149d515f72cee083e87.1/
    /images/icons/profilepics/default.png","width":48,"height":48,"isDefault":true},"username":"yyang82","displayName":"Yixi Yang","userKey":"8a5946ab507f2c0d01507f2c21d80001"},"cre
    atedDate":"2015-10-22T07:50:03.177+02:00","links":{"self":"http://localhost:8090/rest/api/content/1998892/history"},"_expandable":{"lastUpdated":"","previousVersion":"","nextVersion":""}},"version":{
    "by":{"type":"known","profilePicture":{"path":"/s/en_GB/5994/3a465f7321af83b92e8f7149d515f72cee083e87.1/
    /images/icons/profilepics/default.png","width":48,"height":48,"isDefault":true},"username":"yya
    ng82","displayName":"Yixi Yang","userKey":"8a5946ab507f2c0d01507f2c21d80001"},"when":"2015-10-22T07:50:03.177+02:00","message":"","number":1,"minorEdit":false},"ancestors":[],"container":{"id":753665,
    "key":"MYS","name":"My Space 1 v2","type":"global","_links":{"self":"http://localhost:8090/rest/api/space/MYS"},"_expandable":{"icon":"","description":"","homepage":"/rest/api/content/524292"}},"body"
    :{"storage":{"value":"This is a temporary page.","representation":"storage","_expandable":{"content":"/rest/api/content/1998892"}},"_expandable":{"editor":"","view":"","export_view":"","anonymous_expo
    rt_view":""}},"extensions":{"position":"none"},"_links":{"webui":"/display/MYS/Page+Temp+1","tinyui":"/x/LIAe","collection":"/rest/api/content","base":"http://localhost:8090","context":"","self":"http
    ://localhost:8090/rest/api/content/1998892"},"_expandable":{"metadata":"","operations":"","children":"/rest/api/content/1998892/child","descendants":"/rest/api/content/1998892/descendant"}}
    response.text:
    {"results":[{"id":"1998892","type":"page","status":"current","title":"Page Temp 1","extensions":{"position":"none"},"_links":{"webui":"/display/MYS/Page+Temp+1","tinyui":"/x/LIAe","self":"http://local
    host:8090/rest/api/content/1998892"},"_expandable":{"container":"","metadata":"","operations":"","children":"/rest/api/content/1998892/child","history":"/rest/api/content/1998892/history","ancestors":
    "","body":"","version":"","descendants":"/rest/api/content/1998892/descendant","space":"/rest/api/space/MYS"}}],"start":0,"limit":25,"size":1,"_links":{"self":"http://localhost:8090/rest/api/content?t
    ype=page&title=Page+Temp+1 http://localhost:8090/rest/api/content?type=page&title=Page+Temp+1","base":"http://localhost:8090","context":""}}
    response.text:

    response.text:
    {"results":[],"start":0,"limit":25,"size":0,"_links":{"self":"http://localhost:8090/rest/api/content?type=page&title=Page+Temp+1","base":"http://localhost:8090","context":""}}

    • case 2:

    if request_type == "DELETE":
    print "response.text:"
    print response.text
    returnelse:
    return response.content if raw else json.loads(response.text)

    response.text:

    —
    Reply to this email directly or view it on GitHub
    #9 (comment)
    .

  5. added a commit that references this issue on Nov 5, 2015
  6. rpcope1 commented on Nov 5, 2015

    @rpcope1
    Owner

    Sorry, this slipped under my radar a little bit. I just pushed a fix that may hopefully fix this.

  7. yangyixizg commented on Nov 9, 2015

    @yangyixizg
    Author

    super, thx for updating, it is fixed now. May I ask you if you would extend the your PythonConfluenceAPI by an other authentication, e.g. NTLM?

  8. rpcope1 commented on Nov 9, 2015

    @rpcope1
    Owner

    I'm not immediately sure how to do that, but I'll look into it.

    On Mon, Nov 9, 2015 at 4:32 AM, yixiyangh notifications@github.com wrote:

    super, thx for updating, it is fixed now. May I ask you if you would
    extend the your PythonConfluenceAPI by an other authentication, e.g. NTLM?

    —
    Reply to this email directly or view it on GitHub
    #9 (comment)
    .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions