Drupal 8 Rest API - drupal-8

My Custom API's are working fine, I've deployed code on staging Server but I'am getting below error.
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Drupal\rest\Plugin\Type\ResourcePluginManager are: dblog, file:upload, entity:block, entity:block_content_type, entity:block_content, entity:comment, entity:comment_type, entity:config_pages_type, entity:config_pages, entity:contact_form, entity:contact_message, entity:editor, entity:field_config, entity:field_storage_config, entity:file, entity:filter_format, entity:flagging, entity:flag, entity:google_api_service_client, entity:google_api_client, entity:image_style, entity:menu_link_content, entity:node, entity:node_type, entity:page_variant, entity:page, entity:path_alias, entity:rdf_mapping, entity:rest_resource_config, entity:search_api_task, entity:search_api_server, entity:search_api_index, entity:search_api_autocomplete_search, entity:shortcut_set, entity:shortcut, entity:social_auth, entity:menu, entity:action, entity:taxonomy_term, entity:taxonomy_vocabulary, entity:tour, entity:ultimate_cron_job, entity:user, entity:user_role, entity:webform_options, entity:webform, entity:webform_submission, entity:webform_access_group, entity:webform_access_type, entity:webform_image_select_images, entity:webform_options_custom, entity:view, entity:paragraph, entity:paragraphs_type, entity:base_field_override, entity:entity_view_display, entity:entity_view_mode, entity:entity_form_mode, entity:entity_form_display, entity:date_format, user_registration in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /home1/tourcode/public_html/''/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php)
Thanks in Advance.

Drupal is looking for a plugin with empty string as a name.
I also noticed have some kind of an empty string in your path. (between public_html and web)
/home1/tourcode/public_html/''/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php
It looks like the configuration of your server has a problem.

Related

create an order on Prestashop API : error with module name

I'm trying to create an order through the Prestashop API (v1.6.1.13). I havn't written any module, my goal is just to use its API without installing anything on the prestashop.
Creating an order requires a module name. If I leave it blank I get the error:
Validation error: "Property Order->module is empty"
If I write a fake name it says :
Validation error: "Property Order->module is not valid"
What should I do ? While I have the same issue with the payment field ?
Here is what I'm sending :
<prestashop>
<order>
<id_address_delivery>1299</id_address_delivery>
<id_address_invoice>1300</id_address_invoice>
<id_cart>218</id_cart>
<id_currency>1</id_currency>
<id_lang>2</id_lang>
<id_customer>214</id_customer>
<id_carrier>2</id_carrier>
<current_state>2</current_state>
<module></module>
<invoice_number>0</invoice_number>
<delivery_number>0</delivery_number>
<valid>1</valid>
<date_add>2017-06-27 23:00:46</date_add>
<date_upd>2017-06-28 11:50:13</date_upd>
<id_shop_group>1</id_shop_group>
<id_shop>1</id_shop
<payment>MyPayment</payment>
<recyclable>0</recyclable>
<gift>0</gift>
<mobile_theme>0</mobile_theme>
<total_discounts>0</total_discounts>
<total_discounts_tax_incl>0</total_discounts_tax_incl>
<total_discounts_tax_excl>0</total_discounts_tax_excl>
<total_paid>27</total_paid>
<total_paid_tax_incl>27</total_paid_tax_incl>
<total_paid_tax_excl>27</total_paid_tax_excl>
<total_paid_real>27</total_paid_real>
<total_products>27</total_products>
<total_products_wt>27</total_products_wt>
<total_shipping>0</total_shipping>
<total_shipping_tax_incl>0</total_shipping_tax_incl>
<total_shipping_tax_excl>0</total_shipping_tax_excl>
<carrier_tax_rate>0</carrier_tax_rate>
<total_wrapping>0</total_wrapping>
<total_wrapping_tax_incl>0</total_wrapping_tax_incl>
<total_wrapping_tax_excl>0</total_wrapping_tax_excl>
<conversion_rate>1</conversion_rate>
<reference>170627369</reference>
<associations>
<order_rows>
<order_row>
<product_id>2</product_id>
<product_attribute_id>7</product_attribute_id>
<product_quantity>2</product_quantity>
<product_name>Blouse</product_name>
<product_reference>demo_2</product_reference>
<product_ean13>0</product_ean13>
<product_price>27</product_price>
<unit_price_tax_incl>27</unit_price_tax_incl>
<unit_price_tax_excl>27</unit_price_tax_excl>
</order_row>
</order_rows>
</associations>
</order>
</prestashop>
Any help/idea would be greatly appreciate, thanks !
After some debug steps in the payment module I found the solution.
The module should be a valid module name (I use "bankwire") and payment can be wathever you want (the name of the external source for example).
I was testing an address which country was disabled... Enabling the country fix the issue.
What a pity Prestashop doesn't respond the reason on the API call... Even if activating the DEV mode of prestashop and DEBUG of the PaymentModule.
Thanks for your help sarcom !
You need Enable the payment options(like payment by check) in prestashop admin side and then need to add the module with prefix ps_moduleName without any space.
I did like this,
$xml->order->module= "ps_".strtolower(str_replace(' ', '', $order_data['payment_method']));
You can try this if there is any error or If you have any better solution then it me know.
Thanks.

Validate Fedex Location Search Request

We have integrated Fedex API in a ruby on rails application .
We need nearest drop off locations . We want to filter locations by DANGEROUS_GOODS_SERVICES.
We have checked the fedex locationService pdf file and we found the following xml request format that we are requesting .
Request
<SearchLocationsRequest xmlns="http://fedex.com/ws/locs/v3">
<UserCredential>
<Key>XXXXXXXXXXXX</Key>
<Password>XXXXXXXXXXXXXX</Password>
</UserCredential>
<WebAuthenticationDetail/>
<ClientDetail>
<AccountNumber>XXXXXXXXXX</AccountNumber>
<MeterNumber>XXXXXXXXX</MeterNumber>
<Region>us</Region>
</ClientDetail>
<Version>
<ServiceId>locs</ServiceId>
<Major>1</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<EffectiveDate>2016-04-13</EffectiveDate>
<LocationsSearchCriterion>ADDRESS</LocationsSearchCriterion>
<Address>
<StreetLines>811 E 1950 N</StreetLines>
<City>Spanish Fork</City>
<StateOrProvinceCode/>
<PostalCode>84660</PostalCode>
<UrbanizationCode/>
<CountryCode>US</CountryCode>
<Residential>0</Residential>
</Address>
<PhoneNumber/>
<GeographicCoordinates/>
<MultipleMatchesAction>RETURN_ALL</MultipleMatchesAction>
<SortDetail>
<Criterion>DISTANCE</Criterion>
<Order>LOWEST_TO_HIGHEST</Order>
</SortDetail>
<Constraints>
<RadiusDistance>
<Value>10.0</Value>
<Units>KM</Units>
</RadiusDistance>
</Constraints>
</SearchLocationsRequest>
Response
{"SearchLocationsReply"=>{"HighestSeverity"=>"ERROR", "Notifications"=>{"Severity"=>"ERROR", "Source"=>"prof", "Code"=>"1000", "Message"=>"Authentication Failed"}, "Version"=>{"ServiceId"=>"locs", "Major"=>"1", "Intermediate"=>"0", "Minor"=>"0"}}}
Authentication failed message we are getting, while the same credentails are working for getting rates and labels.
I had the same problem than you, after several hours I discovered that the problem was some invisible characteres copied from the fedex email confirmation. In a text editor was possible to see them:
Be careful with the strange characters at the begin and at the end of the key/passwords.
The problem was solved after strip those characters.

Image file extension randomly is missing in sitecore

I'm experiencing an strange behaviour in our production servers.
We have three servers and It seems sometimes MediaManager.GetMediaUrl doesn't return the file extension. First I thought one server might have different settings. I compared all the configs on the three servers and they are identical.
Surprisingly, I notice If I browse the same page from the same server I can replicate issue.
I checked the value of Media.RequestExtension and for all three is same as following
<setting name="Media.RequestExtension" value=""/>
I cannot replicate the issue on none of our environments( local,test, staging )
I added the metatag and hardcoded the server name and I set the Cacheable property of usercontrol to false and I'm sure it's not Caching issue.
var images = new List<string>();
var imageField1 = (Sitecore.Data.Fields.ImageField)Sitecore.Context.Item.Fields["og Image1"];
if (imageField1 != null && imageField1.MediaItem != null)
{
var image1Url = MediaManager.GetMediaUrl(imageField1.MediaItem);
images.Add(image1Url);
}
Has anyone experienced the same issue?
Even I have faced this issue of extension in media item urls.
Workaround for this issue would be to make use of IncludeExtension property of MediaUrlOptions object.
MediaUrlOptions mediaUrlOpts = new MediaUrlOptions();
mediaUrlOpts.IncludeExtension = false;
Response.Write(MediaManager.GetMediaUrl(item, mediaUrlOpts ));
If you want to always add extension to URL, then set IncludeExtension to true.

SBL-ODU-01007 The HTTP request did not contain a valid SOAPAction header

I am hoping someone can help get me in the right direction...
I am using Powerbuilder 12 Classic and trying to consume a Oracle CRM OnDemand web service.
Using Msxml2.XMLHTTP.4.0 commands, I have been able to connect using https and retrieve the session id, which I need to send back when I invoke the method.
When I run the code below, I get the SBL-ODU-01007 The HTTP request did not contain a valid SOAPAction header error message. I am not sure what I am missing??
OleObject loo_xmlhttp
ls_get_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=login"
try
loo_xmlhttp = CREATE oleobject
loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP.4.0")
loo_xmlhttp.open ("GET",ls_get_url, false)
loo_xmlhttp.setRequestHeader("UserName", "xxxxxxx")
loo_xmlhttp.setRequestHeader("Password", "xxxxxxx")
loo_xmlhttp.send()
cookie = loo_xmlhttp.getResponseHeader("Set-Cookie")
sesId = mid(cookie, pos(cookie,"=", 1)+1, pos(cookie,";", 1)-(pos(cookie,"=", 1)+1))
ls_post_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration/Activity;"
ls_response_text = "jsessionid=" + sesId + ";"
ls_post_url = ls_post_url + ls_response_text
loo_xmlhttp.open ("POST",ls_post_url, false)
loo_xmlhttp.setRequestHeader("COOKIE", left(cookie,pos(cookie,";",1)-1) )
loo_xmlhttp.setRequestHeader("COOKIE", left(cookie,pos(cookie,";",1)-1) )
ls_post_url2 = "document/urn:crmondemand/ws/activity/10/2004:Activity_QueryPage"
loo_xmlhttp.setRequestHeader("SOAPAction", ls_post_url2)
loo_xmlhttp.send()
ls_get_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=logoff"
loo_xmlhttp.open ("POST",ls_get_url, false)
loo_xmlhttp.send()
catch (RuntimeError rte)
MessageBox("Error", "RuntimeError - " + rte.getMessage())
end try
I believe you are using incorrect URL for Login and Logoff;
Here is the sample:
https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=login
https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=logoff
Rest of the code looks OK to me.
I have run into similar issues in PB with msxml through ole. Adding this may help:
loo_xmlhttp.setRequestHeader("Content-Type", "text/xml")
you need to make sure that the your value for ls_post_url2 is one of the values that is found in the wsdl file. Just search for "soap:operation soapAction" in the wsdl file to see the valid values for SOAPAction.

Classic Asp Web Service Problem

I'm trying to create a code to allow an existing classic asp program to use an asp.net web service. Updating from the classic asp is not an option, as I'm working in a big company and things are the way they are.
I've been browsing through a chunk of tutorials supposedly helping in this, but I haven't managed to get them to work yet. As a beginner I might've made some real obvious mistakes but I just don't know what.
First, the web service is located on an external server. The method "Greeting" needs a String parameter by which it determines which String is sent back. Inputting "g" to it procudes this xml:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://server1/Logger_WebService/">Greetings and welcome!</string>
I assume the xpath for getting the contents is either "string/*" or "*"?
Next, my web service itself looks like this:
<WebMethod()> _
Public Function Greeting(ByVal stringel As String) As String
If stringel.ToLower = "g" Then
Return "Greetings and welcome!"
Else
Return "Bye then!"
End If
End Function
The web service works fine from a regular asp.net solution.
Now here's the problem, the classic asp code looks like this (4 different ways I've tried to get this to work, SOAP toolkit is installed on the web service server, all examples taken and modified from tutorials):
'******* USING GET METHOD
Dim wsurl="http://server1/Logger_WebService/service.asmx/Greeting?g"
Dim xmlhttp
Set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET",wsurl,false
xmlhttp.send
Dim rValue
'rValue=xmlhttp.responseXML.selectSingleNode("string") 'use XPATH as input argument
' or you can get response XML
rValue=xmlhttp.responseXML
Set xmlhttp=nothing
'------------------------------------------------------
'******* USING POST METHOD
Dim wsurl="http://server1/Logger_WebService/service.asmx/Greeting"
Dim xmlhttp
Set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST",wsurl,false
xmlhttp.send "stringeli=g"
Dim rValue
rValue=xmlhttp.responseXML.selectSingleNode("string")
' or you can get response XML
' rValue=xmlhttp.responseXML
Set xmlhttp=nothing
'------------------------------------------------------
Response.Write consumeWebService()
Function consumeWebService()
Dim webServiceUrl, httpReq, node, myXmlDoc
webServiceUrl = "http://server1/Logger_WebService/service.asmx/Greeting?stringel=g"
Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpReq.Open "GET", webServiceUrl, False
httpReq.Send
Set myXmlDoc =Server.CreateObject("MSXML.DOMDocument")
myXmlDoc.load(httpReq.responseBody)
Set httpReq = Nothing
Set node = myXmlDoc.documentElement.selectSingleNode("string/*")
consumeWebService = " " & node.text
End Function
'------------------------------------------------------
Response.Write(Helou())
Public Function Helou()
SET objSoapClient = Server.CreateObject("MSSOAP.SoapClient")
objSoapClient.ClientProperty("ServerHTTPRequest") = True
' needs to be updated with the url of your Web Service WSDL and is
' followed by the Web Service name
Call objSoapClient.mssoapinit("http://server1/Logger_WebService/service.asmx?WSDL", "Service")
' use the SOAP object to call the Web Method Required
Helou = objSoapClient.Greeting("g")
End Function
I seriously have no idea why nothing works, I've tried them every which way with loads of different settings etc. One possible issue is that the web service is located on a server which in ASP.Net required me to input this "[ServiceVariableName].Credentials = System.Net.CredentialCache.DefaultCredentials". I do this from within company network, and there are some security and authorization issues.
I only need to be able to send information anyhow, not receive, as the actual method I will be using is going to insert information into a database. But for now, just getting the Hello World thingie to work seems to provide enough challenge. :)
Thx for all the help. I'll try to check back on holiday hours to check and reply to the comments, I've undoubtedly left out needed information.
Please, talk as you would to an idiot, I'm new to this so chances are I can understand better that way. :)
You might consider writing a bit of .NET wrapper code to consume the web service. Then expose the .NET code as a COM object that the ASP can call directly. As you've seen, there is no tooling to help you in classic ASP, so consider using as much .NET as possible, for the tooling. Then, use COM to interoperate between the two.
A colleague finally got it working after putting a whole day into it. It was decided that it's easier by far to send information than it is to receive it. Since the eventual purpose of the web service is to write data to the DB and not get any message back, we attempted the thing by simply writing a file in the web service.
The following changes were needed:
First, in order to get it to work through the company networks, anonymous access had to be enabled in IIS.
The web service needed the following change in the web.config:
<webServices>
<protocols>
<add name="HttpGet"/>
</protocols>
</webServices>
And the web service code-behind was changed like so:
<WebMethod()> _
Public Function Greeting(ByVal stringel As String) As String
Dim kirj As StreamWriter
'kirj = File.CreateText("\\server1\MyDir\Logger_WebService\test.txt")
'if run locally, the line above would need to be used, otherwise the one below
kirj = File.CreateText("C:\Inetpub\serverroot\MyDir\Logger_WebService\test.txt")
kirj.WriteLine(stringel)
kirj.Close()
kirj.Dispose()
Return stringel
End Function
As we got the above to work, it was a simple matter of applying the same to the big web method that would parse and check the info and insert it into the database.
The classic asp code itself that needs to be added to the old page, which was the biggest problem, turned out to be relatively simple in the end.
function works()
message = "http://server1/mydir/logger_webservice/service.asmx/Greeting?" & _
"stringel=" & "it works"
Set objRequest = Server.createobject("MSXML2.XMLHTTP")
With objRequest
.open "GET", message, False
.setRequestHeader "Content-Type", "text/xml"
.send
End With
works = objRequest.responseText
end function
works()
Took about a week's worth of work to get this solved. :/ The hardest part was simply not ever knowing what was wrong at any one time.
You might be missing the SOAPAction header. Here's a working example:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GreetingService : WebService
{
[WebMethod]
public string Greet(string name)
{
return string.Format("Hello {0}", name);
}
}
And the calling VBS script:
Dim SoapRequest
Set SoapRequest = CreateObject("MSXML2.XMLHTTP")
Dim myXML
Set myXML = CreateObject("MSXML.DOMDocument")
myXML.Async=False
SoapRequest.Open "POST", "http://localhost:4625/GreetingService.asmx", False
SoapRequest.setRequestHeader "Content-Type","text/xml;charset=utf-8"
SoapRequest.setRequestHeader "SOAPAction", """http://tempuri.org/Greet"""
Dim DataToSend
DataToSend= _
"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">" & _
"<soapenv:Header/>" & _
"<soapenv:Body>" & _
"<tem:Greet>" & _
"<tem:name>John</tem:name>" & _
"</tem:Greet>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"
SoapRequest.Send DataToSend
If myXML.load(SoapRequest.responseXML) Then
Dim Node
Set Node = myXML.documentElement.selectSingleNode("//GreetResult")
msgbox Node.Text
Set Node = Nothing
End If
Set SoapRequest = Nothing
Set myXML = Nothing
Might want to double-check the version of the MSXML components. Are you using Windows Authentication? I've noticed some odd XML parsing problems with IIS 7, Classic ASP, and MSXML.
It would also help to get a useful error. Check the ** myXML.parseError.errorCode** and if its not 0 write out the error.
Reference Code:
If (myXML.parseError.errorCode <> 0) then
Response.Write "XML error: " & myXML.parseError.reason
Else
'no error, do whatever here
End If
'You get the idea...