Azure API Manager - Issue on URL , working even if no sense url and just getting the last segment - azure-devops

We have found this bug in Api Manager that whenever you pass some similar words in the url its working properly even the url was not correct .
Example:
working url: {{Url}}/regulators
bad url but works with the same : {{Url}}/../auth/streams/../../regulators
Anybody encounter the same issue with your APIs?
Please see image below

Method GET is used to add form data to the URL in name or value pair. If you use GET, the length of URL will remain limited. It helps users to submit the bookmark the result. GET is better for the data which does not require any security or having images or word documents.
Also, this is used only to get the data from address bar in the browser.
We can check with below settings for API Responses:
Select the API you created in the previous step.
Select + Add Operation.
In the Frontend window, enter the following values.
Display Name(test call) : The name that is displayed in the developer portal.
URL(HTTP Verb) – GET : Select one of the predefined HTTP verbs.
URL (/test) : A URL path for API.
Description: Optional description of the operation, used to provide documentation in the developer portal to the developers using this API.
Select the Responses tab, located under the URL, Display name, and Description fields. Enter settings on this tab to define response status codes, content types, examples, and schemas.
Select + Add response, and select 200 OK from the list.
Under the Representations heading on the right, select + Add representation.
Enter application/json into the search box and select the application/json content type.
In the Sample text box, enter { "sampleField" : "test" }.
Select Save.
Refer to MS Docs to Monitor published API’s

Related

Confluence Cloud - How to update content status via the API

I'm struggling with how to find the content status of a page in Confluence.
My end goal is to be able to change/update via the API.
I've added the list of statuses already in the Manage space section. I have successfully pulled the content of a page as well as its properties, but I can’t seem to find where the content status is stored.
Here is the URI I'm using:
https://MyDomain.atlassian.net/wiki/rest/api/content/145468621376?expand=space,body.storage,view,version.status,container,extentions
That Status is not present in OOB Confluence, so I suppose it is some third-party app from Atlassian Marketplace and you need to check with their documentation how to interact with it.
Of course, you can directly use the REST API to get page content as a string (HTML) and change its content, e.g. using Python (Atlassian Python API’s documentation)
Page actions
def my_page = confluence.get_page_property(page_id, page_property_key)
def new_body = my_page.body.replace("<macro .....>", "<new status in HTML>")
confluence.update_or_create(parent_id, title, new_body, representation='storage')
Finally sorted it out with the help of Atlassian support. If their documentation was correct it would've been super easy to do this.
https://developer.atlassian.com/cloud/confluence/rest/api-group-content-states/#api-group-content-states
Heres the catch. when you GET the status you have to add on the parameter for status even though its optional. so your get string needs to look like this:
your-domain.atlassian.net/wiki/rest/api/content{id}/state?status=current
Same goes for setting the new state. You have to add on the status parameter to the uri.

How to chain requests using Insomnia (get token from login api to use as header for other api)

I'm trying to update the header for my apis with a sif token that is retrieved from another login call. I know how to do this in Postman. There I go to the Tests tab and add something like this for the login api, which would set my global variable.
var data = JSON.parse(responseBody);
postman.setGlobalVariable("SIF_TEACHER", data.sifToken);
I've read this tutorial from the Insomnia official support page but can't really understand it and couldn't find any other doc on chaining requests there.
Thank you.
In your workspace press CTRL+E to open "Manage Environments" window
Add a variable like "token" to the environment
Put a response function (teal f) as value of this variable by pressing CTRL+SPACE.
Select one to your liking from the dropdown, in your case "Response => Body Attribute" should work well.
This will open a "Tag" form, like this one:
Select your login request and filter the response json or xml for the value containing your token value, f.e. $.access_token. Probably set trigger behaviour to "When Expired" too.
You can now access this variable anywhere in your workspace for other requests by pressing CTRL+SPACE in any form field and selecting the variable (purple x).
If you only need this for one request, you can skip setting up the environment variable for this and directly put the function where you need it, same way as described before.
You can check the link, in the comments there is a mini clip with the indications
https://github.com/Kong/insomnia/issues/2744
There is a plugin that allows you to have variables which you can set its value from different request an use them in others. This is great for when you want to chain requests but you have multiple possible parents and don't want to duplicate the child request, for example you could have "Login with A" and "Login with B" and both save to id, then you can have a "Get info" with the id.
Setting a variable is done using an special tag in the header of the request ("Save variable") and then use its value wherever you want with the "Variable" tag.
You can see more about the plugin in https://insomnia.rest/plugins/insomnia-plugin-save-variables .

Calling IBM Function through HTTP

I created a function in IBM cloud which displays some JSON data when invoked. I am trying to figure out how client can consume this information. I am unable to find any information on net. I would like to preferable access the function through HTTP request or if that is not possible do it through some python script. Does anyone have more information on how this can be achieved?
Depending on the nature of your action/function, there are different ways to call it. In any case, you can find the required information about URL (and API key), by clicking the action in the action panel, and select 'endpoints' from there.
If you created a 'plain' action (i.e. one that accepts JSON and returns JSON), you will have to use the API key shown on the panel mentioned above. You can find it -- and the URL to use, in the 'Rest API' section. At the bottom of this page, there is also a complete curl command, which you can just copy & paste (and where you only need to insert the API key).
In case you created a web action (see here for details: https://console.bluemix.net/docs/openwhisk/openwhisk_webactions.html#openwhisk_webactions) , you can call it anonymously. The URL for that is different than the one referred to above -- you can find it in the 'web actions' section of the 'Endpoints' tab.

Orchard's Web Request Workflow activity

I'm currently running Orchard v1.9.3, and I would like to use Orchard's web request workflow activity to make an API call to MailChimp's API (http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#create-post_lists_list_id_members). I was able to determine the value for the URL field should have the following form:
https://us14.api.mailchimp.com/3.0/lists/My_MailChimp_list_id/members/
Since I'm saving data to my MailChimp list, I'm going to select "PUT" for the verb drop down field. Based on MailChimp's API documentation, I was going to enter the following value in the "Headers" field:
'content-type: application/json'
MailChimp expects a JSON-formatted request, so I'm going to choose "Json" in the "Form Format" drop-down field.
The part that I'm struggling with is the "Form Values" field. According to the API docs, the data should have the following format, "'{"email_address":"urist.mcvankab+3#freddiesjokes.com", "status":"subscribed"}'". I know MailChimp expects my e-mail address in lieu of "urist.mcvankab+3#freddiesjokes.com", but I don't understand how to map the first name, last name, and email address values from my Orchard form into this Json request.
According to the documentation you linked to, the API expects a POST request. But maybe it supports PUT all the same, I don't know.
Regarding your question, you can access the submitted FORM values via the following token:
#FormSubmission.Field:MyFieldName
So for example, if the Dynamic Forms field name you used is named EmailAddress, your JSON should look something like this:
{
"email_address":"#FormSubmission.Field:EmailAddress",
"status":"subscribed"
}
PS: Kudos for using Dynamic Forms and the Web Request Activity!

What are the "base URLs" for status, photos, etc?

I developed an app that looks for specific terms using the facebook api (search).
Every result comes with an ID for the item that can be of many types like "status","photos",etc.
I remember that some time ago I could surf facebook and get this URLs from the browser address bar, but now with some updates that facebook has made it seems to be all AJAX based calls and it seems like you do not have a "specific page" for each item.
I looked over the web and could not find anything regarding this.
Is there any way I can get a "photo id" from the API and open it like "http://facebook.com/photos/0293820293842"?
Thanks for any clue.
https://graph.facebook.com/{id}/picture
https://graph.facebook.com/40796308305/picture (by page id)
https://graph.facebook.com/cocacola/picture (by page's name)
https://graph.facebook.com/4/picture (by user id)
https://graph.facebook.com/4/zuck (by user name)
after some time I just gave up trying to get the picture from the data provided by the search API.
From the api I get entries of type "photo" but they do not match with the API documentation found at http://developers.facebook.com/docs/reference/api/photo/ since I do not receive the fields "picture", "source" or "images" (they just does not exist in the results from a search)
Looking to find a way to use the approach of "setting up the URL from the fields received from the API" I could not get any sucess either.
That's one case... I set up a search for "pepsi"... and within the results I got a "photo" object.
In this object I have the following fields:
id: 100002307882828_188072634633218
author\id: 100002307882828
link : "http://www.facebook.com/photo.php?fbid=320417371337648&set=a.133681116677942.17717.131381520241235&type=1" (this link really points to the photo's page, but is not the photo itself)
object_id: 320417371337648
I used the URL you provided as a "base" and tried to setup some combination that returns me a photo but I always get "Content not found" as result.
The only way I could find the final photo URL is to make another call to the API using the Photo Id as parameter (but I would need to do a lot of calls to the API and this just do not fit my scenario)
If I call https://graph.facebook.com/320417371337648 I get everything I need from the photo, but this is the "another call" I would need to perform for each result I get.
Thanks a lot for your help,
Regards,
Victor Reboucas