API call works on postman but not on filemaker - api

I am trying to program an app in filemaker that uses data from an API service. The problem is that when I test an url using postman it returns the JSON file I want without problems, but when i use the insert from url command from Filemaker, the result is a 405 method not allowed error.
As additional information: I'm trying to get a JSON object from the API to a text field inside my Filemaker database, using a script to fill it up.
Here's the script I have in filemaker:
Insert from URL[Select; With Dialog: Off; Projects::JSONdata;
"https://soporte.adasoft.es/rest/api/2/search?jql=project=****&maxResults=10&fields=Id,key,status,name,startdate,details,lastupudated";
Curl Options:"-X GET" &
"-H 'Authorization: Basic
************'" &
"-H 'Cache-Control: no-cache'"]
OBSERVATIONS: I've replaced the sensible data (such as the encrypted simple authentication login) with '*'.

Try this
Insert from URL[Select; With Dialog: Off; Projects::JSONdata;
"https://soporte.adasoft.es/rest/api/2/search?jql=project=****&maxResults=10&fields=Id,key,status,name,startdate,details,lastupudated";
cURL options:
"-X GET" & "--header \"Authorization: Basic *******\"" & "--header \"Cache-Control: no-cache\""]
Reference : https://fmhelp.filemaker.com/help/16/fmp/en/index.html#page/FMP_Help/insert-from-url.html

Related

How to retrieve body form-data in key value pair and use it in postman test script

request body form-data
I tried the following but didnot work
pm.request.body.data
pm.request.data
Access this format
pm.request.body.formdata.get("name")
pm.request.body.formdata.get("last_name")
pm.request.body.formdata.get("other_name")
Documentation in here
formdata :PropertyList.<FormParam>
Form data parameters for this request are held in this field.
Type:
PropertyList.<FormParam>
Usage in Tests tab.

Exporting AUth2.0 bearer token with postman collection file does NOT work when executed using newman on cmd

Below are the steps
Add bearer token env variable, as shown below
Add bearer token to the header on Main collection tab, and the request
as shown below
And now manually check what happens when we run - Get comments request, use the 'inherit auth from parent' option - it shows 200 OK, and returns the comments as shown below
Now export both env variables & collection file as shown below
Run the files on cmd with newman as shown below
Check the result of the 'Get Comments' request
Expected: 200 OK status
Actual : 401 Unauthorized stauts
Any help will be really appreciated, thanks
Every Sub folder should refer to the 'inherit from parent ' in the auth method . In this case, make sure the sub folder ACCOUNT has the auth method set to 'inherit from parent'. And make sure to click the save button before exporting the collection file.

Recieving an "errorCode: ERROR_RESOURCE_GONE" when trying to send play command

I have been trying to figure out the sonos api over the past few days, but unfortuanetly have hit a road block. I have already gotten my tokens and room names and and favorites Id, but when I send the curl request to play a song I get the error described above.
Curl Code :
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer {TOKEN}" "https://api.ws.sonos.com/control/api/v1/groups/RINCON_48A6B88A5B14014XX:XXXXXXXXXX/favorites" --data #play.json
I keep the body in a .json file called play which contains the code:
{
"favoriteId":2,
"playOnCompletion":true
}
I have not been able to find any documentation on this issue online, so any and all help is very appreciated.
The "ERROR_RESOURCE_GONE" HTTP 410 response indicates that the
groupID you are using in your request (RINCON_48A6B88A5B14014XX:XXXXXXXXXX) no longer exists. Group IDs are not static and may change depending on a number of factors - grouping and ungrouping, power cycling, etc.
If you re-run the request to get groups, you should get an up-to-date list of group IDs. Try doing that and using a returned Group ID in your favorites request.
The "Subscribe" section of the documentation describes how to automatically listen for group ID changes: https://developer.sonos.com/build/direct-control/connect/
Have you made sure that the groupId or the favoriteId are still valid? Based on the ERROR_RESOURCE_GONE, it seems one of those has likely changed.

RALLY Webservice 2.0 CRUD using Spring integration

I am trying to do CRUD operations on rally using Rally WS with Spring integration.
I am able to retrieve defect but while calling update, it throws error, It is not accepting any type, I tried with MAP, jsonobject.
Map<String, String> updMap =...
updMap.put("_refObjectName", name+" TEST UPDATE");
RallyUpdater updater = ctx.getBean("rallyUpdateGateway", RallyUpdater.class);
String res=updater.updateDefect(updMap);
my configuration:
<int-http:outbound-gateway id="opgateway" request-channel="rallyUpdateJsonRequest"
url="https://rally1.rallydev.com/slm/webservice/v2.0/defect/9792864541?key={key}"
http-method="POST" request-factory="rallyHttpRequestFactory"
expected-response-type="java.lang.String"
reply-channel="rallyUpdateResponse">
<int-http:uri-variable
name="key"
expression="payload" />
</int-http:outbound-gateway>
<int:object-to-json-transformer input-channel="rallyUpdateRequest" output-channel="rallyUpdateJsonRequest" />
<int:gateway id="rallyUpdateGateway" service-interface="rally.RallyUpdater"
default-request-channel="rallyUpdateRequest" default-reply-channel="rallyUpdateResponse" />
When I send a map, I use a transformer . It throws error saying expected '{'.... .
When I send JsonObject, it is throwing another exception.
Which format I should use?
_refObjectName should not be used to set a name of the object. There is a Name attribute, and that's the one that should be used when setting the name.
The curl command below shows a payload example in json format, when updating an existing Rally artifact, e.g. defect:
curl --header "zsessionid:_abc123" -H "Content-Type: application/json" -d"{\"Defect\":{\"Name\":\"New name\",\"Resolution\":\"Not a Defect\",\"State\":\"Fixed\"}}" https://rally1.rallydev.com/slm/webservice/v2.0/Defect/17822920696
I can't comment on Spring specific details, but json should follow format above. However if you choose to use Rally REST toolkit for Java, you do not have to manually build a payload like that since the toolkit provides convenience methods

Spotify API Add to playlist

Is it possible to manipulate (add to) a Spotify playlist via server side functionality?
The web API seems limited to search (https://developer.spotify.com/technologies/web-api/) and the JavaScript API Reference which has the function seems limited to actually building an app inside Spotify itself...
Yes you can , but you need an authorization process involving the user which is quite painful.
You'll need to use the right API.
Source:
https://developer.spotify.com/web-api/console/playlists/
For example for adding a track, you'll need this end-point
https://api.spotify.com/v1/users/{user_id}/playlists/{playlist_id}/tracks
This codes works on AppleScript, just to prove the concept:
set userID to "XXXXX"
-- your userID can be retrieved with https://developer.spotify.com/web-api/console/get-current-user/#complete
set SelectedPlaylistID to "YYYY"
-- your target playlist can be retrieved with https://developer.spotify.com/web-api/console/get-playlists/#complete
set BearerID to "ZZZZ"
-- ZZZZ can be retrieved manually on page https://developer.spotify.com/web-api/console/post-playlist-tracks/
tell application "Spotify"
set currentSpotifyID to id of current track as string
end tell
set currentlyPlayingTrack to trim_line(currentSpotifyID, "spotify:track:", 0)
set theURL to "'https://api.spotify.com/v1/users/" & userID & "/playlists/" & SelectedPlaylistID & "/tracks?uris=spotify%3Atrack%3A" & currentlyPlayingTrack & "' -H 'Accept: application/json' -H 'Authorization: Bearer " & BearerID & "'"
-- obtenu de https://developer.spotify.com/web-api/console/post-playlist-tracks/#complete
set theCommand to "curl -X POST " & theURL
do shell script theCommand
BUT there is a big caveat : you'll need to refresh the BearerID every hour.
Which is where the authorization process is needed, and where it becomes complicated if you want to bypass the refreshing limit.
Unfortunately, this isn't possible at this time without building a Spotify application either inside the client using the JS API or a standalone app using libSpotify.