If I am querying using the following, then Function CallSFDCAPI works.
services/data/v41.0/query?q=Select+Id+FROM+Vendor__c"
I am required get the response in XML format. But how can i get the response in XML format if I am querying using the following?
/services/data/v41.0/ui-api/object-info/Service_A__c/picklist-values/xxxx/Provider__c
I get the error when trying to GET the picklist values.
System.Net.WebException: 'The remote server returned an error: (406) Not Acceptable.'
Public Function CallSFDCAPI(ByVal Query As String, FileName As String) As String
Dim objSFDCToken As New SFDCToken.GetSFDCToken()
Dim SFDCToken As String = objSFDCToken.SFDCToken()
Dim SFDCQuery As String = String.Format(Query)
Dim TempFolder As String = ConfigurationManager.AppSettings("TempFolder").ToString()
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
Dim httpWebRequest As HttpWebRequest
Dim httpWebResponse As HttpWebResponse
httpWebRequest = WebRequest.Create(SFDCQuery)
httpWebRequest.Method = "GET"
httpWebRequest.ContentType = "application/json"
httpWebRequest.Accept = "application/xml"
httpWebRequest.Headers.Add("Authorization", "Bearer " + SFDCToken)
httpWebResponse = httpWebRequest.GetResponse()
Dim uniqueFileName As String = DateTime.Now.ToString().Replace(":", "_")
uniqueFileName = FileName + "_" + uniqueFileName.Replace("/", "_")
Dim responseStream As Stream = httpWebResponse.GetResponseStream()
Dim sr As StreamReader = New StreamReader(responseStream, Encoding.Default)
Dim sw = New StreamWriter(TempFolder + uniqueFileName + ".xml", False, Encoding.Default)
sw.Write(sr.ReadToEnd())
sw.Close()
sr.Close()
responseStream.Close()
End Function
Any workaround to force a XML return?