I've had code working for several years now and I had to upgrade the project to .Net 4. After upgrading the project, I am getting the following error after accessing any method:
There is an error in XML document (1,1) - hexadecimal value 0x1F, is an invalid character. Line 1 position 1.
Here is a sample of the code I'm attempting to run:
Dim ConsumerKey As String = "XXXXXXXXXXXXXXXXXXXXXX"
Dim UserAgentString As String = "TEST Xero Interface (Private App Testing)"
Dim privateCertificate As X509Certificate2 = New X509Certificate2("C:\Data\public_privatekey.pfx", "xxxxxxx")
Dim uConsumerSession As IOAuthSession = New XeroApiPrivateSession(UserAgentString, ConsumerKey, privateCertificate)
Dim uRepository As New Repository(uConsumerSession)
Dim uInvoice As New Model.Invoice
Dim uContact As New Model.Contact
uContact.Name = "ABC Ltd"
uContact.IsCustomer = True
uInvoice.Contact = uContact
uInvoice.Type = "ACCREC"
uInvoice.Date = Now
uInvoice.DueDate = DateAdd(DateInterval.Day, 14, Now)
uInvoice.Status = "DRAFT"
uInvoice.LineAmountTypes = 0
uInvoice.LineItems = New LineItems
Dim uLineItem = New Model.LineItem
uLineItem.Quantity = 1
uLineItem.ItemCode = "TEST TRANS"
uLineItem.Description = "Testing Router"
uLineItem.AccountCode = "400"
uLineItem.UnitAmount = 200
uInvoice.LineItems.Add(uLineItem)
uRepository.Create(Of Model.Invoice)(uInvoice)
What am I doing wrong here? Why did the same code I've used for years stop working?
TLDR; Your code will be using TLS 1.0 which is deprecated - use the following in your code to force TLS 1.2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
I am sure you have worked this out already but I was getting the same thing, API was returning an undocumented response code 412 so being rejected prior to even getting to the API and doing things,
The error response handling in that Older SDK which you look to be using for .NET was not working that well so was trying to parse the error response hence the error - which put me off for a bit while i debugged.
I decided to upgrade to the new Xeronet SDK which is actively being maintained - https://github.com/XeroAPI/Xero-Net
Then i got the same error except this time the error message was useful, stated that TLS 1.0 was not supported please upgrade, Ah. Ha... they turned support of for this end of June 2018 according to their site, I think it actually happened end of July as I had things working on this code at the end of July.
Anyway upgrade your code ideally to the new SDK and then force .net to use TLS 1.2 using the below if on .net 4.5
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
if using 4.0 then
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
Related
I have my below code which works proper on 106.15, I get a succesfull status. Project is Visual Studio 2022 (.Net 4.8)
accessToken = GetAccessToken()
Dim rRequest As RestRequest
Dim rClient As RestClient
Dim rResponse As RestResponse
Try
Dim data() As Byte = File.ReadAllBytes(fileSource)
rClient = New RestClient("https://graph.microsoft.com/v1.0")
rRequest = New RestRequest(uploadURL, Method.Put)
rRequest.AddHeader("Authorization", "Bearer " & accessToken)
rRequest.AddHeader("Content-Range", New ContentRangeHeaderValue(0, data.Length - 1, data.Length).ToString)
rRequest.AddHeader("Content-Length", data.Length)
rRequest.AddParameter("application/binary", data, ParameterType.RequestBody)
rResponse = Await rClient.ExecuteAsync(rRequest)
When I execute the code on 107.15 it fails with the following error : There was an error sending the request (translated from dutch)
Any idea what could be wrong or should be changed?
Looks like 108.0.1 fixes the issue, it is working now.
This commit from 03 Mar 22 shows the fix.
Please read the documentation.
Don't use this:
rRequest.AddHeader("Content-Range", New ContentRangeHeaderValue(0, data.Length - 1, data.Length).ToString)
rRequest.AddHeader("Content-Length", data.Length)
rRequest.AddParameter("application/binary", data, ParameterType.RequestBody)
use AddFile instead.
You can still add the Content-Range header manually using AddHeader. As you aren't uploading the file (although you kind of do), you might not the file name to be there. In that case, you can try this:
rRequest
.AddBody(data)
.AddHeader("Content-Range", New ContentRangeHeaderValue(0, data.Length - 1, data.Length).ToString())
When AddBody gets a byte array, it will use the application/binary content type, and set the length correctly.
Earlier i have used Dropbox api on personal user account and all goes very fine.
Now, i need to do the same, but this time account is a business account user. I have tried for hours but can't find a working way to upload the file.
Here is my code that i tried:
objDHTTP = New Chilkat.Http
objDHTTP.UnlockComponent("")
objDHTTP.HeartbeatMs = 125
objDHTTP.ConnectTimeout = 60
objDHTTP.ReadTimeout = 60
objDJSON = New Chilkat.JsonObject
objDJSON.AppendString("path", "/test.pdf")
objDJSON.AppendString("mode", "overwrite")
objDJSON.AppendBool("autorename", False)
objDJSON.AppendBool("mute", True)
objDRequest = New Chilkat.HttpRequest
objDRequest.UsePost()
objDRequest.Path = "/2/files/upload"
objDRequest.AddHeader("Content-Type", "application/octet-stream")
objDRequest.AddHeader("Dropbox-API-Select-User", "dbmid:member_id") 'Note-1
objDRequest.AddHeader("Authorization", "Bearer auth_token") 'Note-2
objDRequest.AddHeader("Dropbox-API-Arg", objDJSON.Emit)
objDRequest.StreamBodyFromFile(strLocalFile)
objDResponse = objDHTTP.SynchronousRequest("content.dropboxapi.com", 443, True, objDRequest)
objDJSON.Dispose()
objDJSON = Nothing
If (objDResponse Is Nothing) Then
strDBReturn = "Call failed!"
Else
strDBReturn = objDResponse.BodyStr.Trim
objDResponse.Dispose()
objDResponse = Nothing
End If
objDRequest.Dispose()
objDRequest = Nothing
Code is in vb.net and i use chilkat libray for http and json part.
but it's very easy to understand the code.
Note-1: i have set the header to select member.
Note-2: first i tried Dropbox API, then i am tring Dropbox Business API
it's shows in the response that file is upload and also shows the same path as the http request.. but i can't find the file in the Dropbox (from browser) :(
Here is the DB Response Example:
{"name": "test1.pdf", "path_lower": "/test1.pdf", "path_display": "/test1.pdf", "id": "id:7fQPQ7pubtAAAAAAAAAAFQ", "client_modified": "2018-10-01T13:46:24Z", "server_modified": "2018-10-01T13:46:24Z", "rev": "cee6f9f90", "size": 204181, "content_hash": "318bc8a4b25c3c319b558dda011a8e837caa0dee2b84e1c7deb0d0405bad1bf0"}
any help will be highly appreciated..
thanks in advance
best regards
I am making one application in vb6 which sends mail from an application, it gives me
Run time error - 2147220973 (80040213) The transport failed to contact
to the server
, I did all the given solution gives before
Please help if any one knows solution.
Code:
code:
{
mStrProcName = "MonthlyXlMail_EmployeePerformance"
sFilePath = (App.Path & "\TimeTaken.xls")
iConf.Load -1
Set Flds = iConf.Fields
Set lobj_cdomsg = New CDO.Message
lobj_cdomsg.Configuration.Fields(cdoSMTPServer) = Trim(rsMail!ServerUrl)
lobj_cdomsg.Configuration.Fields(cdoSMTPServerPort) = CInt(Trim(rsMail!Port))
lobj_cdomsg.Configuration.Fields(cdoSMTPUseSSL) = IIf(rsMail!ReqSSL = "Y", True, False)
lobj_cdomsg.Configuration.Fields(cdoSMTPAuthenticate) = cdoBasic
lobj_cdomsg.Configuration.Fields(cdoSendUserName) = Trim(rsMail!EMailID)
lobj_cdomsg.Configuration.Fields(cdoSendPassword) = Trim(rsMail!EmailPassword)
lobj_cdomsg.Configuration.Fields(cdoSMTPConnectionTimeout) = 30
lobj_cdomsg.Configuration.Fields(cdoSendUsingMethod) = cdoSendUsingPort
lobj_cdomsg.Configuration.Fields.Update
lobj_cdomsg.To = Trim(strMail)
lobj_cdomsg.From = Trim(rsMail!EMailID)
lobj_cdomsg.Subject = IIf(Len(Trim(txtsubject.Text)) = 0, "Performance Report", Trim(txtsubject.Text))
lobj_cdomsg.TextBody = IIf(Len(Trim(txtDescription.Text)) = 0, "Find Attachment", Trim(txtDescription.Text))
'lobj_cdomsg.HTMLBody = strMsg
lobj_cdomsg.AddAttachment (sFilePath)
lobj_cdomsg.Send
}
Are you using Gmail with Two factor auth? This also prevents using smtp with basic authentication.
Create a custom app in you Gmail security settings to add a new password for your messaging application.
1. Login into your Gmail account
2. Goto https://security.google.com/settings/security/apppasswords
3. Choose 'Custom' app.
4. Typ 'Gmail Smtp', or something
5. Click 'Generate'
6. It will give you a password token.
Use this token as your password in your messaging application instead of your own password.
I have a dnn 7.2.2 development site running under dnndev.me on my local machine. I have created a simple product catalogue module and am trying to integrate the new search for dnn 7.
Here is the implementation of ModuleSearchBase in my feature/business controller
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Search
Imports DotNetNuke.Common.Globals
Namespace Components
Public Class FeatureController
Inherits ModuleSearchBase
Implements IUpgradeable
Public Overrides Function GetModifiedSearchDocuments(moduleInfo As ModuleInfo, beginDate As Date) As IList(Of Entities.SearchDocument)
Try
Dim SearchDocuments As New List(Of Entities.SearchDocument)
'get list of changed products
Dim vc As New ViewsController
Dim pList As List(Of vw_ProductList_Short_Active) = vc.GetProduct_Short_Active(moduleInfo.PortalID)
If pList IsNot Nothing Then
''for each product, create a searchdocument
For Each p As vw_ProductList_Short_Active In pList
Dim SearchDoc As New Entities.SearchDocument
Dim ModID As Integer = 0
If p.ModuleId Is Nothing OrElse p.ModuleId = 0 Then
ModID = moduleInfo.ModuleID
Else
ModID = p.ModuleId
End If
Dim array() As String = {"mid=" + ModID.ToString, "id=" + p.ProductId.ToString, "item=" + Replace(p.Name, " ", "-")}
Dim DetailUrl = NavigateURL(moduleInfo.TabID, GetPortalSettings(), "Detail", array)
With SearchDoc
.AuthorUserId = p.CreatedByUserId
.Body = p.ShortInfo
.Description = p.LongInfo
.IsActive = True
.PortalId = moduleInfo.PortalID
.ModifiedTimeUtc = p.LastUpdatedDate
.Title = p.Name + " - " + p.ProductNumber
.UniqueKey = Guid.NewGuid().ToString()
.Url = DetailUrl
.SearchTypeId = 2
.ModuleId = p.ModuleId
End With
SearchDocuments.Add(SearchDoc)
Next
Return SearchDocuments
Else
Return Nothing
End If
Catch ex As Exception
LogException(ex)
Return Nothing
End Try
End Function
End Class
End Namespace
I cleared the site cache and then I manually started a search re-index. I can see from the host schedule history that the re-index is run and completes.
PROBLEM
None of the items in the above code are added to the index. I even used the Luke Inspector to look into the lucene index and that confirms that these items are not added.
QUESTION
I need help figuring out why these items are not getting added or I need help on how to debug the indexing to see if anything is going run during that process.
Thanks in Advance
JK
EDIT #1
I ran the following procedure in Sql Server to see if the module is even listed in the search modules:
exec GetSearchModules[PortalId]
The module in question does appear in this list. The indexing is called for the featureController, but the results are not added to the lucene index. Still need help.
EDIT #2
So I upgraded to 7.3.1 in the hopes that something during the installation would fix this issue. But it did not. The search documents are still getting created/ returned by the GetModifiedSearchDocuments function but the documents are not being added to the Lucene index and therefore do not appear in the search results.
EDIT #3
The break point is not getting hit like i thought after the upgrade, but I added a try catch to log exceptions and the following error log is getting created when I try to manually re-index (cleaned up to keep it short)
AssemblyVersion:7.3.1
PortalID:-1
PortalName:
DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke
ExceptionGUID:d0a443da-3d68-4b82-afb3-8c9183cf8424
InnerException:Sequence contains more than one matching element
Method:System.Linq.Enumerable.Single
StackTrace:
Message:
System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at DotNetNuke.Services.Scheduling.Scheduler.CoreScheduler.LoadQueueFromTimer()
at DotNetNuke.Services.Scheduling.Scheduler.CoreScheduler.Start()
Source:
Server Name: KING-PC
EDIT #4
Okay, I fixed the problem in edit three following This Disucssion on the DNN issue tracker, but still no items being added to the lucene index.
The breakpoint is hit, and once i leave the debugger running for a while i get the following error:
{"Exception of type 'Lucene.Net.Index.MergePolicy+MergeException' was
thrown."} {"Cannot overwrite:
C:\websites\dnndev.me\App_Data\Search\_1f0.fdt"}
Looks like a permission error. I'll see what I can work out
J King,
I just finished a series on DNNHero.com on Implementing Search in your Module. Parts 3 and 4 are implementing and debugging your ModuleSearchBase implementation.
EDIT: Remove your assignment to the SearchTypeId in your implementation
Also, here is a sample snippet to see how i am setting the attributes of the SearchDocument. Again, watch my video for a whole bunch of other potential pitfalls in the Search implementation.
SearchDocument doc = new SearchDocument
{
UniqueKey = String.Format("{0}_{1}_{2}",
moduleInfo.ModuleDefinition.DefinitionName, moduleInfo.PortalID, item.ItemId),
AuthorUserId = item.AssignedUserId,
ModifiedTimeUtc = item.LastModifiedOnDate.ToUniversalTime(),
Title = item.ItemName,
Body = item.ItemDescription,
Url = "",
CultureCode = "en-US",
Description = "DotNetNuclear Search Content Item",
IsActive = true,
ModuleDefId = moduleInfo.ModuleDefID,
ModuleId = item.ModuleId,
PortalId = moduleInfo.PortalID,
TabId = tab
};
I'm using GMap.NET in winforms application But when i use Googlesatellite map provider it gives an error ,Exception :The remote Server returned in error:(404) Not found,
Other map providers works fine just problem with "GoogleSatelliteMapProvider",
Heres my code
With gmaps
.Position = New PointLatLng(22.63, 71.58)
.MinZoom = 3
.MaxZoom = 17
.Zoom = 8
.Manager.Mode = AccessMode.ServerAndCache
.CanDragMap = True
GMap.NET.MapProviders.GoogleSatelliteMapProvider.Instance.APIKey = "MyApiKey"
.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance
.DragButton = Windows.Forms.MouseButtons.Left
.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter
End With
Perhaps You are using old version try new version . . . Go here and get new version Greatmap Release