I'm using the prestashop API prestapyt
I add a category by hand in my site, but when I'm trying to edit via the API, it fails.
Even the most simple thing, does not work:
ps = PrestaShopWebServiceDict(config.DOMAIN, config.KEY)
xml = ps.get('categories', 35)
ps.edit('categories',35,xml)
The xml (type DICT) loads ok, but the .edit() fails.
Here is the response
Traceback (most recent call last):
File "C:\Users\noukeys\Documents\psapi\main.py", line 31, in <module>
ps.edit('categories',35,xml)
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 333, in edit
return self.edit_with_url(full_url, content)
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 452, in edit_with_url
return super(PrestaShopWebServiceDict, self).edit_with_url(url, xml_content)
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 344, in edit_with_url
return self._parse(self._execute(url, 'PUT', body=unicode_encode.encode(content), add_headers=headers)[2])
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 171, in _execute
self._check_status_code(status_code)
File "C:\Python27\lib\site-packages\prestapyt\prestapyt.py", line 125, in _check_status_code
% (status_code, message_by_code[status_code]), status_code)
prestapyt.prestapyt.PrestaShopWebServiceError: 'This call to PrestaShop Web Services failed and returned an HTTP status of 400. That means: Bad Request.'
I'm having issues with edits also, but I am getting a 501 error. Turns out my host does not allow PUT requests.
You can turn on debugging in the api.
prestashop.debug = True
And then turn on display_errors in config.inc.php for your shop. This helped me debug why the request was bad. The error messages are pretty clear.
Related
So, I was trying to like a Tweet using Tweepy, but this error is occurring:
Traceback (most recent call last):
File "c:/Users/User/Desktop/VScode/Python/FibraBot_home/bottwitter2.py", line 32, in <module>
tweet.favorite()
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy\models.py", line 371, in favorite
return self._api.create_favorite(self.id)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy\api.py", line 46, in wrapper
return method(*args, **kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy\api.py", line 913, in create_favorite
), id=id, **kwargs
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy\api.py", line 257, in request
raise Unauthorized(resp)
tweepy.errors.Unauthorized: 401 Unauthorized
PS C:\Users\User\Desktop\VScode\Python\FibraBot_home>
Any ideas?
If you’re using a method that performs an action on behalf of the authenticating user, e.g. API.update_status(), make sure your app has the write permission.
After giving it the write permission, make sure to regenerate and use new credentials to utilize it.
https://tweepy.readthedocs.io/en/v4.8.0/faq.html#why-am-i-encountering-a-401-unauthorized-error-with-api-or-403-forbidden-error-with-client
I'm new to coding and I suck. I hope to find help here.
I was playing around with the praw module for reddit and couldn't get the simple function upvote() to work.
Here's my code:
import praw
r = praw.Reddit(client_id='**************',
client_secret='**************',
user_agent='**************',
username='**************',
password='***********')
r.submission('https://www.reddit.com/r/aww/comments/9znyf2/today_is_my_18th_birthday_everyone/').upvote()
And here's the full error:
Traceback (most recent call last):
File "C:\Users\*****\Desktop\*****\*****\*****\*****\*****\A.py", line 11, in <module>
r.submission('https://www.reddit.com/r/aww/comments/9znyf2/today_is_my_18th_birthday_everyone/').upvote()
File "C:\Users\*****\AppData\Local\Programs\Python\Python37\lib\site-packages\praw\models\reddit\mixins\votable.py", line 80, in upvote
self._vote(direction=1)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37\lib\site-packages\praw\models\reddit\mixins\votable.py", line 10, in _vote
'id': self.fullname})
File "C:\Users*****\AppData\Local\Programs\Python\Python37\lib\site-packages\praw\reddit.py", line 465, in post
params=params)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37\lib\site-packages\praw\reddit.py", line 506, in request
params=params)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37\lib\site-packages\prawcore\sessions.py", line 185, in request
params=params, url=url)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37\lib\site-packages\prawcore\sessions.py", line 130, in _request_with_retries
raise self.STATUS_EXCEPTIONS[response.status_code](response)
prawcore.exceptions.NotFound: received 404 HTTP response
PRAW is trying to use that URL as a post ID, not as a URL. url is the second argument to reddit.submission(), so you'll need to use it as a named argument (r.submission(url='https://www.reddit.com/...')) to get the submission. After you do that everything should work as expected.
from fbchat import Client
from fbchat.models import *
client = Client('<username>', '<password>')
print('Own id: {}'.format(client.uid))
client.send(Message(text='Hi me!'), thread_id='clientname', thread_type=ThreadType.USER)
client.logout()
The code sample above is what I got from a tutorial online, the program is able to login to Facebook messenger and tell me my user id. Then I added in a client.send to see if it actually sends a message using facebook messenger to one of my contacts but then i get this in IDLE. Can anybody provide solutions for this issue?
Traceback (most recent call last):
File "C:/Users/User/Desktop/Python/fbchat trial.py", line 10, in <module>
client.send(Message(text='Hi me!'), thread_id='User', thread_type=ThreadType.USER)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 955, in send
return self._doSendRequest(data)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 923, in _doSendRequest
j = self._post(self.req_url.SEND, data, fix_request=True, as_json=True)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 128, in _post
raise e
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 124, in _post
return check_request(r, as_json=as_json)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\utils.py", line 193, in check_request
raise FBchatFacebookError('Error when sending request: Got {} response'.format(r.status_code), request_status_code=r.status_code)
fbchat.models.FBchatFacebookError: Error when sending request: Got 500 response
You may need to try this. I think your thread_id is wrong.
client.send(Message(text='Hi me!'), thread_id=client.uid, thread_type=ThreadType.USER)
I'm getting an error when trying to upload a custom module for a trigger app. I'm not sure what's going on; it looks like maybe a bad response a badly formatted json.
Error in remote call to api.post_files: Forge API call to module/admob/version went wrong: Expecting object: line 9 column 1 (char 174)
Traceback (most recent call last):
File "/Users/kevzettler/Library/Trigger Toolkit/build-tools/forge/async.py", line 106, in run
result = self._target(*self._args, **self._kwargs)
File "/Users/kevzettler/Library/Trigger Toolkit/trigger/api/api.py", line 20, in post_files
return forge_tool.singleton.remote._api_post(method, data=data, cookies=cookies, files=opened_files)
File "/Users/kevzettler/Library/Trigger Toolkit/build-tools/forge/remote.py", line 475, in _api_post
_check_api_response_for_error(url, 'POST', resp)
File "/Users/kevzettler/Library/Trigger Toolkit/build-tools/forge/remote.py", line 121, in _check_api_response_for_error
_raise_if_json_error(content_dict, error_template, resp, url)
File "/Users/kevzettler/Library/Trigger Toolkit/build-tools/forge/remote.py", line 81, in _raise_if_json_error
raise RequestError(resp, error_message, errors=errors)
RequestError: Forge API call to module/admob/version went wrong: Expecting object: line 9 column 1 (char 174)
It looks like the content of your config_schema.json file is invalid.
Unfortunately the error message you see isn't very useful. The good news is newer platform versions have better validation of local files before upload, so if you develop your module against a newer platform version errors like this should be listed in the Toolkit before upload.
I am having trouble upgrading my session token in google app engine if my user is not logged into my application using the google accounts user api. If the user is currently logged in then it functions perfectly.
If not then i am getting this error:
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 511, in __call__
handler.get(*groups)
File "/base/data/home/apps/5th-anniversary/1.341853888797531127/main.py", line 78, in get
u.upgradeToken(self)
File "/base/data/home/apps/5th-anniversary/1.341853888797531127/upload.py", line 47, in upgradeToken
client.UpgradeToSessionToken()
File "/base/data/home/apps/5th-anniversary/1.341853888797531127/gdata/service.py", line 903, in UpgradeToSessionToken
raise NonAuthSubToken
NonAuthSubToken
What are my best options here? I do not want the user to have to log into the google accounts api and then the youtube site to upload a video.
here is my method for updating the token:
def upgradeToken(data,self):
get = self.request.GET
authsub_token = get['token']
gdata.alt.appengine.run_on_appengine(client)
client.SetAuthSubToken(authsub_token)
client.UpgradeToSessionToken()
client is simply client = gdata.youtube.service.YouTubeService()
pretty sure i'm missing something on the authentication side but i can't seem to see what, thanks!
I solved this by using:
client.UpgradeToSessionToken(gdata.auth.extract_auth_sub_token_from_url(self.request.url))
but this raised another issue when building the upload form with
GetFormUploadToken
i receive:
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 513, in __call__
handler.post(*groups)
File "/base/data/home/apps/5th-anniversary/1.341859541699944556/upload.py", line 106, in post
form = u.getUploadForm(self,title,description,keywords)
File "/base/data/home/apps/5th-anniversary/1.341859541699944556/upload.py", line 65, in getUploadForm
response = client.GetFormUploadToken(video_entry,'http://gdata.youtube.com/action/GetUploadToken')
File "/base/data/home/apps/5th-anniversary/1.341859541699944556/gdata/youtube/service.py", line 716, in GetFormUploadToken
raise YouTubeError(e.args[0])
YouTubeError: {'status': 401L, 'body': '<HTML>\n<HEAD>\n<TITLE>User authentication required.</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>User authentication required.</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>\n', 'reason': ''}
Try this:
new_token = client.UpgradeToOAuthAccessToken(
gdata.auth.extract_auth_sub_token_from_url(self.request.url)
client.SetOAuthToken(new_token)
client.GetFormUploadToken(my_video_entry)