Registering a Shopify Webhook via the ShopifyAPI gem - api

This call correctly returns an empty array:
hooks = ShopifyAPI::Session.temp(s.myshopify_domain, s.shopify_access_token) do
ShopifyAPI::Webhook.find :all
end
While this call always returns a 403:
hook = ShopifyAPI::Session.temp(s.myshopify_domain, s.shopify_access_token) do
ShopifyAPI::Webhook.create(
format: 'json',
topic: 'orders/fulfilled',
address: "http://www.something.fr/api/webhooks?store_id=#{s.id }&store_check=#{ s.checksum }"
)
end
I've tried pretty much all solutions offered over various websites, each time with a failure.
What am I missing here?

The whole code block given in original post is correct.
It was in fact a rights problem, the customer who provided us with the API tokens didn't enable webhook creation rights on the Shopify configuration.
It might seem like nothing, but it is critical that you check that with whoever gave you credentials!

Try this
hook = ShopifyAPI::Session.temp(s.myshopify_domain, s.shopify_access_token) do
ShopifyAPI::Webhook.new(
format: 'json',
topic: 'orders/fulfilled',
address: "http://www.something.fr/api/webhooks?store_id=#{s.id }&store_check=#{ s.checksum }"
)
end
Possible duplicate: Error Creating Shopify Webhook through the API

Related

UPDATE and REVISE rest api is not working in vTiger CRM cloud service

So basically I need to use the update/revise Rest API to update the fields in the vTiger CRM.
But when I am using the rest API (link : https://help.vtiger.com/article/147111249-Rest-API-Manual) to update the fields, I am getting the error as "400 Unsupported operations: The request cannot be fulfilled due to bad syntax."
My api : endpoint/reviseelement=convert_into_json_string({id:5x369, potentialname:'demo2'})
Also apart from this, I had used the SQL query Rest API, to update the record in the modules, but it is also giving me the same error as: "400 Unsupported operations: The request cannot be fulfilled due to bad syntax."
My Api query : endpoint/query?query=UPDATE Potentials SET potentialname = 'demo2 where id = 5x369;
Also by using the webservice(https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html) rest api I am getting error like : "Permission to perform the operations is denied for id: ".
So how can I use the update api. Can anyone please help?
For web services API (https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html),
When you pass the payload data, make sure you're passing the x-www-form-urlencoded form of data.
Also, make sure you're passing 'element' argument with value like this:
{"id": "10x11471458", "leadsource": "Facebook"}.
if you're still facing this issue, you can share more details and I'll be happy to help you.
If you still need to do this the following should work.
Method: POST
End Point: /revise
Headers: "Authorization: Basic YOUR_TOKEN"
Body:
{
"element": {
"id":"5x369",
"potentialname": "demo2"
}
}
reference: https://www.vtiger.com/docs/rest-api-for-vtiger#/Revise

Any POST or GET requests from the Revue API return 401

I am trying to add subscribers to my newsletter using the Revue api. According to the documentation, I need to add a header called 'Authorization' and value 'Token MY-TOKEN' in my requests.
In order to test out the API I am using Postman as seen in the screenshot below:
Any request I do to any url, ends up with a 401.
What am I missing here? The token value is copy pasted from the bottom of https://www.getrevue.co/app/integrations ('Your API key is xyz') as the documentation mentions. Double checked that there are no extra spaces added.
You cannot use the API (or at least certain entry points) without first verifying your account
If you fail to do this, your requests end with a 401 status.
Verify your account
There is no explicit option to verify your account. Instead, you need to import an existing mailing list. If you don't have a list to import, you can enforce this step by creating an artificial list, containing just your email. To do so, visit your Revue dashboard, Subscribers section, and click "Import from file":
.
Then, enter your email and two commas to skip your first and last name:
Submit and fill the next form.
When completed, a top ribbon indicates that the review is on its way:
You need to wait for the review to be completed.
Perform a request
To get your API key, visit your Revue dashboard, Account settings, Integrations, and scroll down to the bottom of the page:
Run something like:
const revueApiKey = "[your API key]";
const result = await fetch('https://www.getrevue.co/api/v2/subscribers', {
method: 'POST',
headers: {
Authorization: `Token ${revueApiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ email: "john#example.com", double_opt_in: false })
});
If you have the following when you log in to Revue
"We are reviewing your account."
You will not be able to make API calls and will get a 401.
I've talked to support on the issue and unfortunately, it's undocumented at the moment.
Took nearly a week for me to get reviewed but it's working fine now. It is at the end of the Christmas period so I am hoping they are only temporarily that slow at reviewing accounts.

Getstream.io throws exception when using the "to" field

I have two flat Feed Groups, main, the primary news feed, and main_topics.
I can make a post to either one successfully.
But when I try to 'cc' the other using the to field, like, to: ["main_topics:donuts"] I get:
code: 17
detail: "You do not have permission to do this, you got this error because there are no policies allowing this request on this application. Please consult the documentation https://getstream.io/docs/"
duration: "0.16ms"
exception: "NotAllowedException"
status_code: 403
Log:
The request didn't have the right permissions or autorization. Please check our docs about how to sign requests.
We're generating user tokens server-side, and the token works to read and write to both groups without to.
// on server
stream_client.user(user.user_id).create({
name: user.name,
username: user.username,
});
Post body:
actor: "SU:5f40650ad9b60a00370686d7"
attachments: {images: [], files: []}
foreign_id: "post:1598391531232"
object: "Newsfeed"
text: "Yum #donuts"
time: "2020-08-25T14:38:51.232"
to: ["main_topics:donuts", "main_topics:all"]
verb: "post"
The docs show an example with to: ['team:barcelona', 'match:1'], and say you need to create the feed groups in the panel, but mention nothing about setting up specific permissions to use this feature.
Any idea why this would happen? Note that I'm trying to create the new topics (donuts, all) which don't exist when this post is made. However, the docs don't specify that feeds need to be explicitly created first - maybe that's the missing piece?
If you haven’t already tried creating the feed first, then try that. Besides that, the default permissions restrict a user from posting on another’s feed. I think it’s acceptable to do this if it’s a notification feed but not user or timeline.
You can email the getstream support to change the default permissions because these are not manageable from the dashboard.
Or you can do this call server side as an admin permissions.

intermittent error from rally 'Not authorized to perform action: Invalid key' for POST request in chrome extension

I developed a chrome extension using Rally's WSAPI v2.0, and it basically does the following things:
get user and project, and store them
get current iteration everytime
send a post request to create a workitem
For the THIRD step, I sometimes get error ["Not authorized to perform action: Invalid key"] since end of last month.
[updated]Error can be reproduced everytime if I log in Rally website via SSO before using the extension to send requests via apikey.
What's the best practice to send subsequent requests via apikey in my extension since I can't control end users' habits?
I did see some similar posts but none of them is helpful... and in case it helps:
I'm adding ZSESSIONID:apikey in my request header, instead of user /
password to authenticate, so I believe no security token is needed
(https://comm.support.ca.com/kb/api-key-and-oauth-client-faq/kb000011568)
url starts with https://rally1.rallydev.com/slm/webservice/v2.0/
issue is fixed after clearing cookies for
https://rally1.rallydev.com/, but somehow it appears again some time
later
I checked the cookie when the issue was reproduced, and found one with name of ZSESSIONID and its value became something else rather than the apikey. Not sure if that matters though...
code for request:
function initXHR(method, url, apikey, cbFunc) {
let httpRequest = new XMLHttpRequest();
...
httpRequest.open(method, url);
httpRequest.setRequestHeader('Content-Type', ' application\/json');
httpRequest.setRequestHeader('Accept', ' application\/json');
httpRequest.setRequestHeader('ZSESSIONID', apikey);
httpRequest.onreadystatechange = function() {
...
};
return httpRequest;
}
...
usReq = initXHR ('POST', baseURL+'hierarchicalrequirement/create', apikey, function(){...});
Anyone has any idea / suggestion? Thanks a million!
I've seen this error when the API key had both read-only and full-access grants configured. I would start by making sure your key only has the full-access grant.

Get workspace details in podio api

Is there any way to get work space name and URL if the API request is authenticated as app.
Podio::authenticate_with_app($app_id, $app_token);
PodioSpace::get($space_id);
the above code return PodioForbiddenError
Sorry, but the I don't think this is allowed within the scope hierarchy.
Please refer to https://developers.podio.com/authentication/scopes
But, if you only need space name, id, url and couple of other minor details you could still get it by using fields parameter. This is described here: https://developers.podio.com/index/api (scroll down to the end of page).
Here is how I debug it with Ruby:
Podio.client.authenticate_with_app(<app_id>, <app_token>)
app = Podio::Application.find(app_id, {'fields' => 'space.view(full)'})
puts app['space']['name']
puts app['space']['space_id']
puts app['space']['url']