Hi Graeme,

> Now I have to work out why the parameterised version doesn't work:
> I've taken the post_id into the url and kept the access hard-coded:
>          url = 'https://graph.facebook.com/'+ x[1]
>          print(url)
>          response = requests.delete(url, 
> params={'access_token':'EAAlFB9sQx7wBQKl........
>
> However, when I print the url that goes to the request, I get this:
>
> https://graph.facebook.com/742194719255364_1531586289001525%0A?access_token=EAAlFB9sQx7wBQKl.....
>
> the characters %0A? separate the params bit, and the call fails:
> <Response [400]>
...
> Where did the %0A come from?

It's at the end of x[1].  It's a hex encoding of ASCII LF, a line feed.
You're probably reading in a line from a text file, but not stripping
off the line feed.

    >>> f = open('/etc/passwd')
    >>> l = f.readline()
    >>> l
    'root:x:0:0:root:/root:/bin/bash\n'
    >>> assert l[-1] == '\n'
    >>> l = l[:-1]
    >>> l
    'root:x:0:0:root:/root:/bin/bash'
    >>> 

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2026-09-01 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  https://dorset.lug.org.uk
  New thread, don't hijack:  mailto:[email protected]

Reply via email to