3
Answers

400 bad request angularjs and webapi

 iam getting bad request when i added iamge here 
 
https://test-a.gfxsymphony.com/v1/SurveyApp/AddImageToSection/387e6b32-c1ed-4177-9909-78b8b7e2b62d/Store%20and%20Contacts
 
 
fileChange(event: any, title: string){
let fileList: FileList = event.target.files;
this.upload_file_formdata = new FormData();
if(fileList.length > 0) {
let file = fileList[0];
this.upload_file_formdata.append('file', file, file.name)
this.upload_file_formdata.append('document.ReferenceNotes', '')
this.upload_file_formdata.append('locationCode', this.locationCode)
this.upload_file_formdata.append('sectionName', title)
// this.surveyService.AddImageToSection(this.locationCode, this.title, this.upload_file_formdata)
// .then((response) => {
// this.myConfirmModal.open()
// })
}
}

uploadFiles(title:string){
if(this.upload_file_formdata != undefined){
this.surveyService.AddImageToSection(this.locationCode, title, this.upload_file_formdata)
.then((response) => {
this.myConfirmModal.open()
})
}
}
 
 
AddImageToSection(locationCode: string, sectionName: string, fileformdata: FormData): Promise<String>{
let url = this.httpClient.getRootUrl() + 'SurveyApp/AddImageToSection/' + locationCode + '/' + sectionName;
// let url = "https://test-a.gfxsymphony.com/tacojohns/Survey/Survey/AddImageToSection";
return this.httpClient.post_file(url, fileformdata)
.toPromise()
.then((response: any) => response)
.catch(this.handleError)
}
 
 
post_file(url, data) {
let headers = new Headers();
headers.append('Content-Type', 'multipart/form-data');
headers.append('x-company-code',localStorage.getItem("company_code"));
headers.append('authorization', "Bearer "+localStorage.getItem("token"));

return this.http.post(url, data, {
headers: headers
});
}
 
 
 
.........
survey.ImageUploader = function (configObj) {
var thisObject = this;

configObj = configObj || {};

var fileUploadField = new Ext.form.FileUploadField({
allowBlank: false,
buttonCgf: { text: 'Find' },
emptyText: 'Select a file...',
fieldLabel: 'Select a file',
name: 'file'
});

var referenceField = new Ext.form.TextField({
allowBlank: true,
fieldLabel: 'File Description',
name: 'document.ReferenceNotes',
value: ''
});

var hiddenLocationField = new Ext.form.Hidden({
hidden: true,
hideLabel: true,
name: 'locationCode',
value: configObj.locationCode
});

var hiddenSectionField = new Ext.form.Hidden({
hidden: true,
hideLabel: true,
name: 'sectionName',
value: configObj.sectionName
});

var url = Survey.URL.Survey.addImageToSectionUrl();

Ext.apply(this, {
autoHeight: true,
items: [
fileUploadField,
referenceField,
hiddenLocationField,
hiddenSectionField
],
defaults: { width: 220 },
fileUpload: true,
labelWidth: 200,
standardSubmit: true,
title: 'Add Images to This Section (To upload multiple, repeat the add image process)',
url: url,
buttons: [{
text: 'Add Image',
formBind: true,
handler: function () {
//manually set the ACTION for our form
thisObject.getForm().getEl().dom.action = url;

var submitMask = new Ext.LoadMask(
thisObject.getEl(),
{ msg: 'Uploading...' }
);
submitMask.show();

//submit the form
Ext.Ajax.request({
url: url,
isUpload: true,
form: thisObject.getForm().getEl(),
success: function (response, action) {
submitMask.hide();
if (response.responseXML.title === '') {
//I guess this works for sniffing failure...

referenceField.setValue('');
fileUploadField.setValue('');
Ext.Msg.alert(
'Success!',
'Document uploaded successfully');
}
else {
Ext.Msg.alert(
'Error',
'Error uploading document:<br />' + GFX.Util.getErrorText(response)
);
}
}
});
}
}]
});

Survey.ImageUploader.superclass.constructor.apply(this, arguments);
};
Ext.extend(Survey.ImageUploader, Ext.form.FormPanel, {});
Ext.reg('survey-uploader', Survey.ImageUploader);
///////////////////////////////////////////////////
 
 
[HttpPost]
[RequireOperation(SubmitSurvey.OperationName)]
public virtual ActionResult AddImageToSection(Guid locationCode, string sectionName, HttpPostedFileBase file, DocumentDto document)
{
document.Name = file.FileName;
document.MimeType = file.ContentType;
document.ReferenceNotes = GetReferenceNotes(sectionName, document.ReferenceNotes);
var request = NewDocumentRequest.BuildRequest(CharacteristicOwnerType.Location, locationCode, file.InputStream.GetBytes(), document, RequestContext);
var response = (NewEntityResponse)RequestProcessor.Process(request);
// Must use ExtNewEntityFormSubmissionJson since the caller was a form submission
return ExtNewEntityFormSubmissionJson(response.EntityCode);
}
 
 
 
 
 
 
 
 
 
 
 
Answers (3)
0
Rajkiran Swain

Rajkiran Swain

NA 33.9k 372.4k 7y
LDAP is mostly used by medium-to-large organi­zations. If you belong to one that has an LDAP server, you can use it to look up contact info and the like. Otherwise, if you were just wondering about this acronym, you probably don't need it. But feel free to read on to learn the story of this bit of Internet plumbing.
 
http://www.gracion.com/server/whatldap.html
https://stackoverflow.com/questions/239385/what-is-ldap-used-for
http://searchmobilecomputing.techtarget.com/definition/LDAP 
Accepted
0
Manas Mohapatra

Manas Mohapatra

NA 29.3k 3.3m 7y
LDAP stands for Light weight Directory Access Protocol. It is mature, well-defined, open and industry protocol accessing and maintaining the entries(user info) over internet protocol. It helps to add new, update and delete entries. It is mostly used authentication purpose. If you work in MNC you will have AD user account, this nothing but your LDAP user account.
More info, follow below link,
 
https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol
 
For sharepoint integration, follow below links that may help you:
 
http://www.c-sharpcorner.com/uploadfile/Roji.Joy/sharepoint-form-authentication-using-ldap/
 
https://blogs.msdn.microsoft.com/spblog/2014/09/26/configure-a-sharepoint-2013-web-application-with-forms-based-authentication-with-a-ldap-membership-provider/