How to get a specific datasources from Grafana API without knowing the id? - datasource

I use the Grafana API to create a lot of datasources (dynamically) so I don't know their ID. Now I want to delete a specific datasources from the API so the method is:
Get the specific datasource
Take the id from the response
Delete this datasource
But I can only search all datasources because I don't know the ID and then I'll need to iterate over each datasources and search the one with the same name + ip ? there is no other solution ?
http://docs.grafana.org/reference/http_api/

Seems like you have an old docs page.. How did you find that? I want to make sure it goes away :)
The new http docs contains an api endpoint for getting datasource by name.
You can also delete datasource by name
DELETE /api/datasources/name/:datasourceName
But we currently do not support deleting by ip + name

Related

Jira Custom fields list of real names

Does anyone know if there is a list of what the custom fields equate to when calling jira via an api to bring the results back?
Not sure a way through restapi, but a workaround.
I had similar issue, so I exported JQL result with All fields which gave field names like custom_field012(SomeFieldName) then I had created a reference table with Custom_field and corresponding field name
I found this link worked and brought up a list of all custom fields.
https://MY-JIRA-URL/jira/rest/api/2/field
You also need to have your Jira open in the same browser.

Adding recipient Groups to a CiviCRM Mailing via REST.. how?

I have been able so far to create a new civi Mailing object and populate it, but confusingly I can't see a parameter in that to specify the mail destination group.
For context, I am dealing with Civi using pure REST api from a remote server. I have a solution to getting a custom template onto the server; the new problem is setting a schedule and delivery group, and initiating the send. I am using the python-civicrm library from github as the intermediary on the client.
I presume send happens as a result of setting the schedule -- i.e. I don't need an API call to say 'send mailing'? Is setting 'sheduled date' == 'now' safe or should I set a date of 'now + 1min' or similar?
So that leaves setting the delivery group. We already have groups defined in the DB, and I want to specify the group by name (and preferably be able to verify in advance that a group name is a valid destination, perhaps by doing a group name -> id lookup).
I think there might be a parameter to Mailing create 'groups' which can have keys 'include' and 'exclude'; at least, that's what the web form seems to do. However it's not mentioned in the REST api implementation.
Can anyone offer pointers?
I think you will find all you need in the following link :
Example of api call that is using the group include/exclude : https://gist.github.com/xurizaemon/6775471
Discussion about implementing mailing as an api - http://forum.civicrm.org/index.php?topic=24075.0
Otherwise, if it doesn't work, i suggest that you :
help adding this api in the CiviCRM Core - you could have some help on this on irc #civicrm (and have a look at https://issues.civicrm.org/jira/browse/CRM-11023)
OR create an extension with the api you need. It will be automatically available for REST. If you haven't created an extension yet, i suggest you go to the page http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension. It's quite straightforward with civix installed.
The table you need to check in the database is civicrm_mailing_group
To confirm, the problem was that (a) I needed to use groups[include]=array(ids) as mentioned by samuelsov, but also (b) I needed to use the json={...} form of request through REST, because the HTTP params syntax doesn't support nested data.

SalesForce API: No such column 'AnnualRevenue' on entity 'Account'

While retrieving basic data using the SalesForce REST API, I encountered the following errors. They seem to follow the pattern of; me asking for non-existent fields.
[{"message":"\nSELECT AnnualRevenue,CreatedDate,Id,LastActivityDate\n ^\nERROR at Row:1:Column:8\nNo such column 'AnnualRevenue' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_FIELD"}]
[{"message":"\nSELECT AnnualRevenue,CreatedDate,ConvertedAccountId\n ^\nERROR at Row:1:Column:8\nNo such column 'AnnualRevenue' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_FIELD"}]
[{"message":"\nAccountId,Amount,CloseDate,CreatedDate,ExpectedRevenue,ForecastCategoryName\n ^\nERROR at Row:1:Column:47\nNo such column 'ExpectedRevenue' on entity 'Opportunity'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_FIELD"}]
But the fields obviously exist, I can see them in the my Dev account. Is it possible that, these fields do not exist for certain types of SalesForce Accounts (Professional, Dev, Ultimate, Enterprise etc)?
To get the application working I removed the fields from the SOQL, and instead used different fields, but not all had replacements. Anyhow... any insight is appreciated.
Thanks
I'm not super familiar with the REST API, but this sounds like a privileges issue to me. Are you sure that the account you are using can see these fields? Check Field Level Security. I'm pretty sure that Expected Revenue, for example, is invisible by default.
These fields should exist for all versions of Salesforce.

Jira SOAP API custom field

Hi I'm am trying to get the list of issues from a JIRA server using the SOAP API provided by JIRA.
I'm trying to filter the issues based on a custom field (and latter I will want to set that custom field).
If I get the list of issue it returns the custom fields for those issues along with them (I get customfieldId, key, values for each custom field) and I can get the custom field with getCustomFields methods provided by the API (to look for the ID of the field with a given name).
The issue I have is that if I login with an account that is not an admin (using the API) I can't call the getCustomFields method (it throws an exception saying I have to be an admin to do that).
My question is: Is there any other way to know which is the ID of the custom field I desire that can be done using a normal user account?
Also if you know how to set a custom field for an issue, it would also be very helpful :) (I would also like to be able to do it with a regular user account).
You have to be an admin to get a list of custom fields. Any 'normal' account can act on the custom fields via the API provided the user knows the customfield ID.
You can set the value of a custom field too, even with a 'normal' account. Again, the user needs the appropriate permissions to do this. Example provided here.
More here and here.
You can also use getFieldsForEdit(token, issueKey), which will return RemoteField[] for all fields available for edit on that issue (even if it has not yet been defined on the issue). It does not require admin permissions, but because it has the word "Edit" in the method, it does require that you have permission to edit the issue (which means, e.g., if the issue is status=Closed, it will raise an exception unless you allow editing closed issues. Unfortunately, I have yet to find a way to retrieve the RemoteField[] list (in order to map id to name), so getCustomFields() and getFieldsForEdit() appear to be the only options.
Have you tried getting a list of issues from the project, picking one, zeroing out the data, and using that as a template? That might work.
SOAP is being deprecated in favor of the REST API, which also has a better method to get this information

Simple mod_rewrite rule.....?

I have a edit page that looks at record_id's in the url.. I don't want the user to see any record id, that way they can't replace it with another and edit another record....
Anyways, my url is like:
http://www.mywebsite.com/folder/folder_detail_edit.php?recordID=3980
I would like it to just display:
http://www.mywebsite.com/folder/folder_detail_edit.php
Is this possible regardless of the recordID???
You should use the http post method to send this data to the server, this way, it won't be visible in the url.
Take a look here
The central problem is not that the record ID is visible and thus can be replaced but that your application allows your users to modify all records. That’s an authorization problem. And hiding the ID does not solve that since the record has to be identified somehow.
You should better implement some authorization mechanism so that your users can only access and modify those records that they are allowed to.