AFNetworking post request fails due to nsdictionary value with double quotes - objective-c

When I set nsdictionary as request parameters, dictionary values with special character are added with double quotes and that cause the post request to failed but when I use same dictionary values using "Rest client (Chrome Add-ons)" request post successfully. How to fix the issue?
for example lat and long should be float value because of special character double quotes are added automatically. Here is my NSDictionary log->
**
AptSuiteNo = 20;
BuildingName = "the ";
BuiltInYear = 2014;
BuiltUpAreaSize = 200;
CityName = Dhaka;
CountryName = Bangladesh;
CreateDate = "19-04-2016";
CreatedByCompanyID = 7746;
CreatedByUserID = 7915;
CurrencyID = 1;
Description = "The ";
LastUpdateDate = "19-04-2016";
LastUpdatedByUserID = 7915;
Latitude = "23.832637";
LocalityName = Cantonment;
Longitude = "90.416590";
NeighborhoodName = "Nikunja 2";
PlaceID = ChIJieh0al7GVTcRvMjqALwGYVc;
PostedBy = owner;
Price = 200;
PropertyBathroomNumber = 1;
PropertyBedroomNumber = 1;
PropertyBuildUpAreaSizeTypeID = 1;
PropertyID = 0;
PropertyLotSize = 250;
PropertyLotSizeTypeID = 1;
PropertyName = "the ";
PropertyTransactionTypeCategoryID = 1;
PropertyTransactionTypeID = 1;
PropertyTypeID = 10;
StateName = "Dhaka Division";
StateTicker = "Dhaka Division";
ZipCode = 1229;
**
NSMutableURLRequest *request = [[AFJSONRequestSerializer serializer] requestWithMethod:#"POST" URLString:RequestURL parameters:[self requestDataString] error:&error];

Related

How to extract NSString from NSDictionary that contains nested JSON

I'm trying to get NSStrings from an dictionary but the extracted strings contain the following
<__NSSingleObjectArrayI 0x28205fc00>(
Aaron
)
I expected s plain NSString.
Code:
NSString *name = [jsonDict valueForKeyPath:#"users.fName"];
NSLog(#"name, %#", name);
I though that using 'objectAtIndex' might work but it didn't.
Structure of NSDictionary (JSON) that I'm working with.
{
TYPE = UPDATE;
keys = (
{
calendarId = b306db7e1f924fdebade3813dd596f5d;
delFlag = 0;
editTime = "2019-10-23T12:02:32.0857328";
endTime = "2019-10-24T10:35:00";
insId = 20;
itemKeyId = 15;
keyId = ce71bc7ae3c145adad18a72e56cf0fab;
projectId = 950710ab2b96413cbfd186141e147b3e;
startTime = "2016-05-23T21:10:00";
updateStatus = 1;
validateCount = 6;
}
);
users = (
{
calendarId = 0;
delFlag = 0;
editTime = "2019-10-23T12:02:32.0794244";
fName = Aaron;
insId = 20;
itemUserId = 15;
keyId = ce71bc7ae3c145adad18a72e56cf0fab;
keyMac = 50338B11E912;
lName = Joines;
operId = 30222e0b4b0e4df6b669c3cf69245422;
projectId = 950710ab2b96413cbfd186141e147b3e;
userId = 8be21d1690bb46979a04b4e45a1ba625;
userPin = 123456;
}
);
}

ODBC-2028 Error SAP B1

I am trying to add a purchase order by DI API for SAP B1. My code is working on my client but I tried it as an addon on another company that has different data. And it gives the error: "No matching records found(ODBC-2028)". Here is a part of my code:
public void createPOrderFor(int id,
string itemCode,
string itemName,
int qty,
int satisSip,
string cardCode,
string cardName,
string releaseDate)
{
SAPbobsCOM.Documents BO_item;
BO_item = (SAPbobsCOM.Documents)getCompany().GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
base.doConnectionInfo();
server = base.server;
database = base.database;
user = base.user;
pass = base.pass;
string year = releaseDate.Substring(0, 4);
string month = releaseDate.Substring(4, 2);
string day = releaseDate.Substring(6, 2);
releaseDate = year + "-" + month + "-" + day;
BO_item.Lines.ItemCode = itemCode;
BO_item.Lines.ItemDescription = itemName;
BO_item.Lines.Quantity = qty;
BO_item.Lines.ShipDate = DateTime.Parse(releaseDate);
BO_item.Lines.UserFields.Fields.Item("U_SatisSip").Value = satisSip;
BO_item.Lines.Add();
BO_item.Comments = satisSip + " numaralı satış siparişine istinaden";
BO_item.CardCode = cardCode;
BO_item.CardName = cardName;
BO_item.NumAtCard = "";
BO_item.Series = 13;//birincil
//BO_item.Segment -- it is read only.
BO_item.TaxDate = DateTime.Now;
BO_item.DocDate = DateTime.Now;
BO_item.DocDueDate = DateTime.Parse(releaseDate);
BO_item.SalesPersonCode = 4;//default Hakan Yılmaz
BO_item.DocumentsOwner = 4;
BO_item.DiscountPercent = 0.0;
BO_item.Address2 = "TURKEY";
BO_item.Address = "";
BO_item.TransportationCode = 1;
BO_item.AgentCode = null;
BO_item.JournalMemo = "Satınalma siparişleri - " + cardCode;
BO_item.GroupNumber = 1;//net30
BO_item.PaymentMethod = null;
BO_item.Project = null;
BO_item.UserFields.Fields.Item("U_SatSip").Value = satisSip;
var retVal = BO_item.Add();
int errorCode = 0;
string errMsg = "";
if (retVal != 0)
{
getCompany().GetLastError(out errorCode, out errMsg);
SAPbouiCOM.Framework.Application.SBO_Application.StatusBar.SetText("Error: " + errMsg , SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
}
First of all remove all null fields. If there are DI Object fields that you cannot provide a value for, you should not set them equal to null.
BO_item.AgentCode = null;
BO_item.PaymentMethod = null;
BO_item.Project = null;
Just remove them completely. Also instead of Date.Time.Now try setting a date in this format: 20180531 for all date fields as a test.
BO_item.DocDate = "20180531"
If it returns the same error, attempt to test this in an SAP Business One Demo Database (can be obtained from sap partneredge).
Also, Ensure the User Defined Fields you are trying to set values for exist in your new customer's database
let me know how it works for you so we can continue.

Get 1 Segment of a Array

I want to get from my Array only on section.
This is my result...
(
{
foreName = FORENAME1;
gender = female;
id = 15;
key = 12345678901;
longName = LASTNAME1;
name = FORELAST1;
},
{
foreName = FORENAME2;
gender = male;
id = 52;
key = 12345678902;
longName = LASTNAME2;
name = FORELAST2;
},
{
foreName = FORENAME3;
gender = male;
id = 77;
key = 12345678903;
longName = LASTNAME3;
name = FORELAST3;
}
)
How can I search for id 77 and get the whole entry array for id 77 like the following example?
{
foreName = FORENAME3;
gender = male;
id = 77;
key = 12345678903;
longName = LASTNAME3;
name = FORELAST3;
}
That result is an array, and you want the element who's id==77...
- (NSDictionary *)elementInArray:(NSArray *)array withId:(NSNumber *)anId {
// there are a lot prettier ways, but this will be the clearest
for (NSDictionary *d in array) {
if ([d[#"id"] isEqual:anId]) return d;
}
return nil;
}
// call it like this
NSArray *array = // the array logged in the OP
NSDictionary result = [self elementInArray:array withId:#77];
NSLog(#"%#", result);

How to extract data values and added to tableview

How to extract the data from the below data structure, and display on tableview
id = extractData
[extractData objectForKey:#"data"] //BELOW IS OUTPUT:
( {
Name = {
id = 2;
name = rat;
};
Place = {
id = 7;
name = New York;
};
Item = {
Times = "100";
“expire” = 10-19-2015;
“value” = 300;
id = 1;
name = newname;
“checked” = 0;
};
Type = {
id = 1;
name = round;
};
},
{
Name = {
id = 2;
name = norway;
};
Place = {
id = 3;
name = ops;
};
Item = {
Times = "100";
“expire” = 10-18-2015;
“value” = 300;
id = 1;
name = new;
“checked” = 1;
};
Type = {
id = 2;
name = square;
};
}
)
Want to display Name,Place,Item,Type values in tableview cell with each iterations.
Can any one advice, how can extract value from above data.
Under your cellForRowAtIndexPath after initializing the custom cell add this code :
NSDictionary *dicVal = [yourDataArray objectAtIndex:indexPath.row];
cell.labelName.text = [[dicVal objectForKey:#"Name"] objectForKey:#"name"];
cell.labelPlace.text = [[dicVal objectForKey:#"Place"] objectForKey:#"name"];
cell.labelItem.text = [[dicVal objectForKey:#"Item"] objectForKey:#"name"];
cell.labelType.text = [[dicVal objectForKey:#"Type"] objectForKey:#"name"];
return yourCustomCell;
This should do the work. Thanks.

Why doesn't Core Data just save all that works and ignore the empty entity?

Given the following console output, why is my Core Data save failing?
It seems that the biz entity is empty. I have 20 "biz" entities, and only 1 is most likely empty. Why does the whole save fail?
Why doesn't Core Data just save all that works and ignore the empty entity? Instead, it returns Error in saving Error in Saving Error Domain=NSCocoaErrorDomain Code=1570.
Here's my console log:
2011-11-08 11:37:49.059 BadgerNew[3808:4503] <0x38a520 GrabClass.m:(509)> Biz to save <Business: 0x32e2550> (entity: Business; id: 0x32b7dd0 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF255489> ; data: {
Bookmark = 0;
Building = nil;
City = "0x32f06e0 <x-coredata:///City/t069264E3-D89C-4D4A-92D9-8A190B7CF255396>";
Distance = "484.0799568283629";
Districts = (
"0x326b7a0 <x-coredata:///District/t069264E3-D89C-4D4A-92D9-8A190B7CF255398>"
);
Email = nil;
ID = 22302;
Images = (
"0x32df100 <x-coredata:///Image/t069264E3-D89C-4D4A-92D9-8A190B7CF255494>"
);
InBuildingAddress = "Blok De Unit 1-2";
LatitudeLongitude = "0x32755f0 <x-coredata:///LatitudeLongitude/t069264E3-D89C-4D4A-92D9-8A190B7CF255495>";
Like = 0;
OpeningHour = nil;
Phones = (
"0x32def60 <x-coredata:///Phone/t069264E3-D89C-4D4A-92D9-8A190B7CF255493>",
"0x32e2d60 <x-coredata:///Phone/t069264E3-D89C-4D4A-92D9-8A190B7CF255490>",
"0x32dea90 <x-coredata:///Phone/t069264E3-D89C-4D4A-92D9-8A190B7CF255491>",
"0x32decb0 <x-coredata:///Phone/t069264E3-D89C-4D4A-92D9-8A190B7CF255492>"
);
Price = 0;
Promotions = (
);
Rating = "0x3275000 <x-coredata:///Rating/t069264E3-D89C-4D4A-92D9-8A190B7CF255496>";
Reviews = (
);
Street = "Jl. Panjang Kedoya No. 1";
Tags = (
);
TimeStamp = nil;
Title = "Bank BNI Graha Elok Mas";
URLs = (
);
Website = nil;
Zip = 11520;
pinAndLineNumber = 0;
})
2011-11-08 11:37:49.095 BadgerNew[3808:4503] <0x427c0 TreadClass.m:(82)> Error in Saving Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x31fbd0 {NSValidationErrorObject=<Business: 0x328c660> (entity: Business; id: 0x332840 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF255441> ; data: {
Bookmark = 0;
Building = nil;
City = nil;
Distance = "-1";
Districts = (
);
Email = nil;
ID = "";
Images = (
);
InBuildingAddress = nil;
LatitudeLongitude = nil;
Like = 0;
OpeningHour = nil;
Phones = (
);
Price = 0;
Promotions = (
);
Rating = nil;
Reviews = (
);
Street = nil;
Tags = (
);
TimeStamp = nil;
Title = nil;
URLs = (
);
Website = nil;
Zip = nil;
pinAndLineNumber = 0;
}), NSValidationErrorKey=Title, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}
2011-11-08 11:37:51.307 BadgerNew[3808:1403] <0x427c0 TreadClass.m:(82)> Error in Saving Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x322ca30 {NSValidationErrorObject=<Business: 0x323f510> (entity: Business; id: 0x323f6a0 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF25511> ; data: {
Bookmark = 0;
Building = nil;
City = nil;
Distance = "-1";
Districts = (
);
Email = nil;
ID = "";
Images = (
);
InBuildingAddress = nil;
LatitudeLongitude = nil;
Like = 0;
OpeningHour = nil;
Phones = (
);
Price = 0;
Promotions = (
);
Rating = nil;
Reviews = (
);
Street = nil;
Tags = (
);
TimeStamp = nil;
Title = nil;
URLs = (
);
Website = nil;
Zip = nil;
pinAndLineNumber = 0;
}), NSValidationErrorKey=Title, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}
2011-11-08 11:37:53.284 BadgerNew[3808:1b03] <0x427c0 TreadClass.m:(82)> Error in Saving Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x3a4c90 {NSValidationErrorObject=<Business: 0x32aee0> (entity: Business; id: 0x300480 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF255220> ; data: {
Bookmark = 0;
Building = nil;
City = nil;
Distance = "-1";
Districts = (
);
Email = nil;
ID = "";
Images = (
);
InBuildingAddress = nil;
LatitudeLongitude = nil;
Like = 0;
OpeningHour = nil;
Phones = (
);
Price = 0;
Promotions = (
);
Rating = nil;
Reviews = (
);
Street = nil;
Tags = (
);
TimeStamp = nil;
Title = nil;
URLs = (
);
Website = nil;
Zip = nil;
pinAndLineNumber = 0;
}), NSValidationErrorKey=Title, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}
2011-11-08 11:37:56.480 BadgerNew[3808:4403] <0x427c0 TreadClass.m:(82)> Error in Saving Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x3c5e10 {NSValidationErrorObject=<Business: 0x32d4530> (entity: Business; id: 0x3d0240 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF255296> ; data: {
Bookmark = 0;
Building = nil;
City = nil;
Distance = "-1";
Districts = (
);
Email = nil;
ID = "";
Images = (
);
InBuildingAddress = nil;
LatitudeLongitude = nil;
Like = 0;
OpeningHour = nil;
Phones = (
);
Price = 0;
Promotions = (
);
Rating = nil;
Reviews = (
);
Street = nil;
Tags = (
);
TimeStamp = nil;
Title = nil;
URLs = (
);
Website = nil;
Zip = nil;
pinAndLineNumber = 0;
}), NSValidationErrorKey=Title, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}
This previous answer explains it best. To quote from the accepted answer:
It means there's a mandatory property has been assigned nil. Either in
your *.xcodatamodel check the "optional" box or when you are saving to
the managedObjectContext make sure that your properties are filled in.