I want to access a database from Zoho Creator using their REST API (https://www.zoho.com/creator/help/api/rest-api/rest-api-add-records.html) I read that I cannot do that from the client side (because CORS isnt implemented or something along those lines) and that I would have to do it from a server.
So I setup a local server using django and I ran a script from the terminal that should add a record to my zoho database, but it doesnt work...
I'm not sure if the script is wrong or if the way I use the server is wrong.
The server is ran by django, I made a simple server with the command "django-admin startproject mysite" and ran the server with "python manage.py runserver".
The name of the app is "synonyms-database", the form is "Main_Form" and the only field there is is called "name". So with that info I followed the API instructions and this is my script:
import requests
payload = {'authtoken': myAPIToken, 'scope': 'creatorapi', 'name': 'test'}
response = requests.request('POST',
'https://creator.zoho.com/api/erik341/json/synonyms-
database/form/Main_Form/record/add/', json=payload)
print(response.headers)
print(response.text)
print(response.url)
And I get this response:
<body>
<div>
An error has occurred. It has been reported to Zoho Creator
support. We will look into this issue .<br> Sorry for the
inconvenience caused.
<p><p>
Go to <a href='%2F'>Home</a>
</div>
</body>
If instead of json=payload I use data=payload the response changes to:
{"code":2945,"message":"INVALID_TICKET"}
The API expects form-encoded data so you should use data=payload instead of json=payload. The json in the URL is the format for the response format, not the request.
You might be able to solve the INVALID_TICKET error by regenerating the token. There's a comment on this post which solved the error by changing the URL from .eu to .com. Make sure that you generate the auth token on a URL that matches your request URL.
Related
I have done all the setup to verify my receipts server side (in python with the requests package).
Here is my code :
url = "https://buy.itunes.apple.com/verifyReceipt"
request_body = {"receipt-data": token}
headers = {'Content-Type': 'application/json'}
response = requests.post(url=url, headers=headers, data=request_body)
The only variable here is token that is sent from the client (flutter) and that is : purchaseDetails.verificationData.serverVerificationData.
I can't verify the receipt because if i pass token as string, i receive always a 21002 error (malformed).
If i try something like this in python :
token = base64.b64encode(token)
It throws this error : a bytes-like object is required, not 'str' which i don't understand because i am actually passing a bytes object.
What is the correct format to pass to the POST request to verify the iOS receipt ?
Is the flutter one correct or should we encode something ?
Any concrete example will be accepted because i could not find any.
PS : i am redirected to the sandbox url "https://sandbox.itunes.apple.com/verifyReceipt" if the production one fails. The sandbox response is the same as the production one (statusCode: 21002)
It looks like either your receipt is not correct ( sandbox has issues sometimes ) or your server-side setup is wrong
For the first point, you can try creating a receipt by generating a storeKit config file.
This can't be done in flutter, you have to open iOS module with code and setup storekit config file by going here.
After setting up the storekit file, you can either run the app from xCode directly or just close xCode and run from your preferred flutter IDE
Now, iOS will never hit the production purchase identifiers when you try to fetch/buy products from the app, and instead fetch the products from your storekit config and generate a receipt from those. This receipt is accepted by apple sandbox verification endpoint, you can also test refunds and subscription cancellations from xCode using a storekit config.
For the second point, you have to enable the app specific shared secret in iTunes connect and then use that in the 'password' key in the receipt validation API.
Here is where you find it
AppStoreConnect > Your app > Subscriptions
If it still doesn't solve the issue, I'd be happy to assist further.
EDIT: I just tested purchasing an auto renewable subscription purchased in sandbox (not storeki
t) and then validating it using the sandbox URL and it returned the correct receipt data. In your post above, you don't need to base64 encode the purchaseDetails.verificationData.serverVerificationData since its already encoded. Have you tested this on postman? It Works there
EDIT: so the request is malformed because you are not sending data as String so you need to dump the dict :
request_body = json.dumps({"receipt-data": token})
I have a NodeJS server and I want to GET data that is coming from python with the POST method.
pythonData.js
const router = require('express').Router()
router.get("/data",(req,res)=>{
console.log(res)
})
module.exports = router
data.py
import requests
data = {"Car": "BMW","Testing":"API"}
request = requests.post("http://localhost:5000/python/data",data=data)
print(request.status_code)
print(request.text)
but when I run my python file I got an error
404
Error Cannot POST
/python/data
Also how do I get it in my NodeJS
You have implemented a GET method in Node, but you are doing a POST from Python.
Try changing the router.get to router.post in your Express server.
You express router function is processing GET request.
Change this to process POST request.
Documentation: https://python-gerrit-api.readthedocs.io/en/latest/
Code
gerrit = GerritClient(base_url="https://gerrit.xx.com",username='xxx',password='xxx')
change = gerrit.changes.get("xxx")
ab=change.get_revision("32423")
print(ab.get_commit().list_change_files())
Question
For some endpoints, I am able to send get responses from the rest api but via this package I get this error(gerrit.utils.exceptions.NotFoundError: 404 Client Error). I am able to get response from Get Rest api for this url: gerrit.xx.xx.com/a/projects/xxxx/commits/xxxx/files via postman. But error with above code.
Looks like this is a bug, I have fixed it and made a pull request. See: https://github.com/shijl0925/python-gerrit-api/pull/5
I am learning django and trying to complete my first webapp.
I am using shopify api & boilder plate (starter code) and am having an issue with the final step of auth.
Specifically, the redirect URL -- it's using HTTP:// when it should NOT and I don't know how to change it..
#in my view
def authenticate(request):
shop = request.GET.get('shop')
print('shop:', shop)
if shop:
scope = settings.SHOPIFY_API_SCOPE
redirect_uri = request.build_absolute_uri(reverse('shopify_app_finalize')) #try this with new store url?
print('redirect url', redirect_uri) # this equals http://myherokuapp.com/login/finalize/
permission_url = shopify.Session(shop.strip()).create_permission_url(scope, redirect_uri)
return redirect(permission_url)
return redirect(_return_address(request))
Which is a problem because my app uses the Embedded Shopify SDK which causes this error to occur at the point of this request
Refused to frame 'http://my.herokuapp.com/' because it violates the following Content Security Policy directive: "child-src 'self' https://* shopify-pos://*". Note that 'frame-src' was not explicitly set, so 'child-src' is used as a fallback.
How do i change the URL to use HTTPS?
Thank you so much in advance. Please let me know if I can share any other details but my code is practically identical to that starter code
This is what the Django doc says about build_absolute_uri:
Mixing HTTP and HTTPS on the same site is discouraged, therefore
build_absolute_uri() will always generate an absolute URI with the
same scheme the current request has. If you need to redirect users to
HTTPS, it’s best to let your Web server redirect all HTTP traffic to
HTTPS.
So you can do two things:
Make sure your site runs entirely on HTTPS (preferred option): Setup your web server to use HTTPS, see the Heroku documentation on how to do this. Django will automatically use HTTPS for request.build_absolute_uri if the incoming request is on HTTPS.
I'm not sure what gets passed in the shop parameter but if it contains personal data I'd suggest to use HTTPS anyway.
Create the URL yourself:
url = "https://{host}{path}".format(
host = request.get_host(),
path = reverse('shopify_app_finalize'))
But you will still need to configure your server to accept incoming HTTPS requests.
I am not able to send request payload to my POST service from WSO2.
On rest console, my service is working.
From WSO2 server I am able to do curl to my server with successful response.
here is my API configuration
Payload to send:
{"query":"Hi I am a POST query parameter"}
My server is receiving {} as request payload. It expect RAW body in JSON (as above) in payload. I have tried all combinations for Parameter Type, but still not able to send payload to my server from WSO2.
How can I do this?
EDIT 1
I have tried all possible ways of sending data including following.
Am I doing something wrong here???
and
From both I get error that my payload is empty or incorrect!!
Edit 2
I am able to connect with Java based services but not with Python based services.
Do I need any special settings on my python server?
enable wirelogs and check following
payload is coming into the API manager (swagger -> AM )
Payload is going out from api manager (AM -> backend)
Also check the request headers coming in and going out and compare them with the stuff from curl request (successful request)
I am using Flask and I am afraid Flask can not deal with this issue currently.
I could reproduce this issue, the message send to back-end correctly, but Python only handle message until timeout.
Python Flask cannot receive post request from WSO2
The work-round may be using Java or Python get method.
I solved this problem by using apache to proxy this request.
I think this is related with wsgi.
Processing chunked encoded HTTP POST requests in python (or generic CGI under apache)
ProxyPass / http://localhost:8001/
ProxyPassReverse / http://localhost:8001/