Magento REST API - How to determine the API base URL? - magento

I'm running Magento 2.2.5 and was having trouble working out what the URL was for making API requests. For example to GET a list of countries I had seen the following syntax used:
/rest/default/V1/directory/countries
which has worked on some stores, but I was getting this error:
{
"message" : "Specified request cannot be processed.",
"trace" : null
}
I started playing around with the URL format and removed the "default" and used this instead:
/rest/V1/directory/countries
and the requests were then successful. How does one determine what the base URL to use for Magento REST API requests? I haven't been able to find this documented so far.

The syntax of Magento 2 Api is
http://<:host:>/rest/<:store_code:>/<:api_path:>
Here store_code can be any one of the "store view" of your Magento2 instance. You can get the store code in admin panel. You can use store_code to get information specific to that Store View via API. By default Magento2 installation comes with 1 website, 1 store & 1 store view (this store-view has code "default", in your case this might have changed hence you get the error).
The architecture can be understand with the help of image
Reference Image
Ref: https://docs.magento.com/m2/ce/user_guide/stores/websites-stores-views.html
When you specify store_code it checks information for that particular Store-View. If the specified store_code is not found in the database, Api returns "Specified request cannot be processed." message.
When you do not specify store_code it first finds default Website, then finds default Store for this Website & then finds default Store View Associated to this Store. And finally it returns information for this default Store-View. The association of default store & store-view can be changed from admin panel.
Reference Image
Hence the URL for API should be below in case you need store specific information. store_code can be set to all if you need information for all the stores.
http://<:host:>/rest/<:store_code:>/<:api_path:>

Related

File ID different from the URL File ID - Google Drive API

I'm trying to access a file in a Google Drive directory but linking to it using the File Id provided by the API it says that i don't have permission. What i saw is that the File Id in the URL is different from the one who returns from the API. Why?
Using the test page of the Google Api it returns a "Not Found" error(404) and not the "No Permissions" error. Anybody knows how to get this ID(same of the url) that links to the file instead of the File's ID
Edit: Found that the File Resource has a property called "webViewLink" is it the link to the file instead of using the ID?
When you are trying the Drive API, you can set using fields property what values you want to return from your call as it is shown in this image:
webViewLink will return you the link that's shown when you open the file in your browser.
id will return you the ID of the file.
I specified some values, but you can see HERE all the values you could use and if you put "*" you will return all of them. Also, I didn't show in the image the id of the file to not share that info.
HERE you can see why you are getting that error. Surely, you don't have enough permitions because you have already checked that it exists for what I understood in your question.

Magento REST API - "Specified request cannot be processed" Error [duplicate]

I'm running Magento 2.2.5 and was having trouble working out what the URL was for making API requests. For example to GET a list of countries I had seen the following syntax used:
/rest/default/V1/directory/countries
which has worked on some stores, but I was getting this error:
{
"message" : "Specified request cannot be processed.",
"trace" : null
}
I started playing around with the URL format and removed the "default" and used this instead:
/rest/V1/directory/countries
and the requests were then successful. How does one determine what the base URL to use for Magento REST API requests? I haven't been able to find this documented so far.
The syntax of Magento 2 Api is
http://<:host:>/rest/<:store_code:>/<:api_path:>
Here store_code can be any one of the "store view" of your Magento2 instance. You can get the store code in admin panel. You can use store_code to get information specific to that Store View via API. By default Magento2 installation comes with 1 website, 1 store & 1 store view (this store-view has code "default", in your case this might have changed hence you get the error).
The architecture can be understand with the help of image
Reference Image
Ref: https://docs.magento.com/m2/ce/user_guide/stores/websites-stores-views.html
When you specify store_code it checks information for that particular Store-View. If the specified store_code is not found in the database, Api returns "Specified request cannot be processed." message.
When you do not specify store_code it first finds default Website, then finds default Store for this Website & then finds default Store View Associated to this Store. And finally it returns information for this default Store-View. The association of default store & store-view can be changed from admin panel.
Reference Image
Hence the URL for API should be below in case you need store specific information. store_code can be set to all if you need information for all the stores.
http://<:host:>/rest/<:store_code:>/<:api_path:>

File upload and download from Filenet

We are working on integration Dynamics CRM with Filenet. This requires support of the following two scenarios:
Upload a document in Filenet through web service and retrieve a unique URL for uploaded document from Filenet
Download document through unique URL of Filenet
Development platform is .NET.
Any ideas about the integration mechanism for same? Is there any webservice exposed by Filenet which we can consume for above 1 & 2 requirements?
The url's in filenet are always in a fixed format, so that's not difficult.
http://P8_client_server_name/application_name:port/getContent?objectStoreName={84A4A727-37E2-4994-B060-8531FAF75612}&objectType=document&id={559946a8-2007-4096-AC67-773A8540AE6}
So call the getContent page with the parameters opbjectstore name or ID, objecttype and the id of the document.
Here is an article about the format of the url's it should help you for the downloading part.
About the uploading,
Here are some API samples about sorting a document in the content engine. With the Id created were you can construct the url to return to the client.
In addition to the previous response, for downloading you can also construct a URL for IBM Content Navigator like this
http://myserver.mycompany.com:9080/navigator/bookmark.jsp?desktop=AccountsPayable&repositoryId=AP_P8_System&docid=30dd879c-ee2f-11db-8314-0800200c9a66&template_name=APtemplate&version=released
where
desktop Specifies which desktop to log in to.​ Specify the ID that is
displayed for the desktop in the ID column on the Desktops tab in the
administration tool. Format: desktop=desktop_ID
repositoryId Specifies the server to log in to.​ Specify the ID that
is displayed for the server in the ID column on the Repositories tab
in the administration tool. Format: repositoryId=repository_ID
docid The system-generated identification number for the document.
Uses the template_name value as the prefix to this folder ID. Format:
docid=document_ID
template_name Document, Folder, or the name of the custom document
class or item type. Format: template_name=template_name
version current, released, or a specific version number. Format:
version=version_number
vsld The IBM FileNet® P8 version series object, which is the Globally
Unique Identifier (GUID), that is associated with the document.
Format: vsld=GUID_number
Using Navigator menu:
You can get URLs for documents or folders when you select the item and
click Actions > View link.

After creating resource on the FHIR server, how can you read its logical ID?

According to the specification here, if you create a resource the server should return a 201 created along with a Location header which contains the new Logical Id and Version Id of the created resource.
I am uploading a patient resource to http://fhir.healthintersections.com.au/open/Patient and using the Chrome debug tools I can see that a 'Content-Location' response header is returned that contains the Logical ID but I cannot access this using jqXHR.getResponseHeader('Content-Location') or jqXHR.getAllResponseHeaders().
After much searching, the problem seems to be that unless the Access-Control-Expose-Headers
header is added to server, I can't view the header within my application as it is a cross origin request.
Is there another way around this problem so I can find the logical ID after creation of a resource?
FHIR exposes it's metadata (id, version specific id, last updated) only in the headers, so you really need to get to that Location header to get a newly created resource's id. There might be a work-around, which is using the "search" operation to retrieve a feed with only this newly created resource (assuming it has identifying business keys like patient id). The resource's atom entry will have an with the id.
That said, that's truly a hack. This is not a FHIR related issue however (see for example How to get responseheader location by jquery).
To fix this problem, I'll update my FHIR server (at spark.furore.com/fhir) to include these Access-Control-Expose headers. It should be updated in the next few hours, so you can try whether that works for you.

Domain Name Windows Vista Does Not Exist In The Database

I am trying to install DOTNETNUKE model on my local machine ( Windows Vista) but seem to be running into a problem right after installing the Database. Not exactly sure where to go to fix the problem or what I need to do next. Anyone have any idea how I can deal with this? Thanks in advance.
DotNetNuke Error
--------------------------------------------------------------------------------
Domain Name Windows Vista Does Not Exist In The Database
DotNetNuke supports multiple portals from a single database/codebase. It
accomplishes this by converting the URL of the client browser Request to
a valid PortalID in the Portals database table. The following steps
describe the process:
Web Server Processing
When a web server receives a Request from a client browser, it compares the
file name extension on the target URL resource to its Application Extension
Mappings defined in IIS.
Based on the corresponding match, IIS then sends the Request to the defined
Executable Path ( aspnet_asapi.dll in the case of ASP.NET Requests ). The
aspnet_isapi.dll engine processes the Request in an ordered series of events
beginning with Application_BeginRequest.
HttpModule.URLRewrite OnBeginRequest ( UrlRewriteModule.vb )
The Request URL is parsed based on the "/" character
A Domain Name is constructed using each of the relevant parsed URL segments.
Examples:
URL: http://www.domain.com/default.aspx = Domain Name: www.domain.com
URL: http://209.75.24.131/default.aspx = Domain Name: 209.75.24.131
URL: http://localhost/DotNetNuke/default.aspx = Domain Name: localhost/DotNetNuke
URL: http://www.domain.com/virtualdirectory/default.aspx = Domain Name: www.domain.com/virtualdirectory
URL: http://www.domain.com/directory/default.aspx = Domain Name: www.domain.com/directory
Using the Domain Name, the application queries the database ( Portals table -
PortalAlias field ) to locate a matching record.
Note: If there are multiple URLs which correspond to the same portal then the
PortalAlias field must contain each valid Domain Name in a comma seperated list.
Example:
URL: http://localhost/DotNetNuke/default.aspx
URL: http://MACHINENAME/DotNetNuke/default.aspx
URL: http://209.32.134.65/DotNetNuke/default.aspx
PortalAlias: localhost/DotNetNuke,MACHINENAME/DotNetNuke,209.32.134.65/DotNetNuke
Note: If you are installing the application to a remote server you must
modify the PortalAlias field value for the default record in the Portals
table according to the rules defined above.
Its hard to tell the status of your installation. I'll assume that the database was created and populated during install.
Firstly, look at the table
dbo.PortalAlias
If your planning to run/debug on your local IIS, then you should have an entry for HTTPAlias of
localhost/YOURVIRTUALDIR
When you installed, it is possible that the last step, the default installation of the Portal did not execute. In a similar case, when I selected "Custom" installation, I found that this last step was missing, but didn't yield an error.
Resolution: reinstall (remove everything or install to a new location, use another DB or remove this one prior to reinstalling) and select "Auto" installation for the online wizard. This works and includes the creation of the default portal. Anything automatically configured can be altered later anyway.
I know this might be very late, but for anyone having this issue,
I had the same issue, after I made sure that I have updated the "Portal Alias" table in db, to have a HTTP Alias (for my local host, I set it to localhost:8089 which was equal to what I had set up in IIS binding for DNN website), with the portal ID of 0 (as my portal id was 0),
I was checking to be sure I have updated web.config file with data base connection strings, but then I realized there were two points for database connection in web.config, and I was missing one of them.
So make sure to update both two connections as:
1) <connectionStrings>
2) <appSettings>
Hope this helps.

Resources