I am trying to POST the below json using the Microsoft Dynamics WebAPI. The post returns a success, but in my data the ccseq_employeeid and ccseq_clientid are not set. What do I need to change to get the fields to post correctly?
Entity Structure
ccseq_expensetransaction has a lookup to ccseq_expensetransactionsets with a relationship that has the name ccseq_ccseq_expensetransactionset_ccseq_expensetransaction_ExpenseTransactionSetID. The lookups to systemusers and ccseq_clients are a part of the ccseq_expensetransaction entity.
Code
POST /api/data/v8.0/ccseq_expensetransactionsets HTTP/1.1
Host: url.com
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 24f7ead3-0307-996f-f45a-f959c604c922
{
"ccseq_importdate":"2017-06-05T04:00:00Z",
"ccseq_month":"1",
"ccseq_year":"2017",
"ccseq_name":"Test 30",
"ccseq_status":"100000000",
"ccseq_ccseq_expensetransactionset_ccseq_expensetransaction_ExpenseTransactionSetID":[
{
"ExpenseTransaction[ccseq_employeeid#odata.bind]":"/systemusers(6d2fd71b-32d1-dd11-a4f5-001a6449bbe7)",
"ExpenseTransaction[ccseq_clientid#odata.bind]":"/ccseq_clients(663ebd00-73b9-4faf-90ed-f56bb9c2dc9b)"
}
]
}
Modify the body of the request into this:
{
"ccseq_importdate": "2017-06-05T04:00:00Z",
"ccseq_month": "1",
"ccseq_year": "2017",
"ccseq_name": "Test 30",
"ccseq_status": "100000000",
"ccseq_employeeid#odata.bind": "/systemusers(6d2fd71b-32d1-dd11-a4f5-001a6449bbe7)",
"ccseq_clientid#odata.bind": "/ccseq_clients(663ebd00-73b9-4faf-90ed-f56bb9c2dc9b)"
}
Related
I am trying to make a POST request to the Sabre CarAvailability API with Postman. When I make the request I get back the following error: Username value length exceeds 20 characters.
I obtained a bearer token and added it to the authorization section of my request
I added the carAvailabilityRequest object as raw data, in the body section of the request.
I tried changing the values of this object, but so far without luck. I know I am doing something wrong but I have no idea what.
Here is the carAvailabilityRequest object I passed:
{
"OTA_VehAvailRateRQ":
{
"TimeStamp": "string",
"Version": "string",
"ReturnHostCommand": true,
"VehAvailRQCore":
{
"RPH": 0,
"QueryType": "Quote",
"VehRentalCore":
{
"PickUpDateTime": "03-31T09:00",
"ReturnDateTime": "04-05T11:00",
"PickUpLocation":
{
"LocationCode": "DFW",
"CityLocation": "string"
},
"ReturnLocation":
{
"LocationCode": "DFW"
}
}
}
}
}
The request does not get through and I get the following error message:
{
"Fault": {
"faultcode": "{http://schemas.xmlsoap.org/soap/envelope/}Client.EbXmlFieldTooLong",
"faultstring": "Username value length exceeds 20 characters",
"detail": {
"StackTrace": [
"com.sabre.universalservices.base.exception.InvalidEbXMLException: errors.xml.USG_EBXML_FIELD_TOO_LONG"
]
}
},
"Links": [
{
"rel": "self",
"href": "https://api-crt.cert.havail.sabre.com/v2.4.1/shop/cars"
},
{
"rel": "linkTemplate",
"href": "https://api-crt.cert.havail.sabre.com/<version>/shop/cars"
}
]
}
Please help me solve this issue - thanks in advance.
Just from the message "Username value length exceeds 20 characters" I would expect that something is wrong with your authentification.
When following the link in your error response https://api-crt.cert.havail.sabre.com/v2.4.1/shop/cars it says again that something is wrong with your authentification/the authentification data is missing:
It seems that something is not configured correctly with your authentification/bearer token or are you maybe sending to a wrong endpoint?
Something else you could try is setting the Content-Type of your request body to application/json because the API documentation you provided seems to define it this way.
You can do this in Postman in the Headers tab of your request:
I tried it out myself with the same error message using the version v2.4.1
If you make the same request to a previous version you will get an appropiate answer.
Use v2.4.0
https://api-crt.cert.havail.sabre.com/v2.4.0/shop/cars
HTH
Pablo.
I'm trying to post fulfillment data on SubmitFeed using javascript in sapui5 and i have done the steps as,
1) I have created json object for fulfillment data and converted it into XML again XML converted into MD5.
JSON code:-
{
"AmazonEnvelope": {
"-xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"-xsi:noNamespaceSchemaLocation": "amznenvelope.xsd",
"Header": {
"DocumentVersion": "1.01",
"MerchantIdentifier": "Example"
},
"MessageType": "OrderFulfillment",
"Message": {
"MessageID": "1",
"OperationType": "Update",
"OrderFulfillment": {
"AmazonOrderID": "102-8289425-201934",
"FulfillmentDate": "2017-06-20T00:36:33-08:00",
"FulfillmentData": {
"CarrierName": "UPS",
"ShippingMethod": "Second Day",
"ShipperTrackingNumber": "1234567890"
},
"Item": {
"AmazonOrderItemCode": "1234567",
"MerchantFulfillmentItemID": "1234567",
"Quantity": "2"
}
}
}
}
};
2) Created signature as per the api documents.
3) Post the data on Feed/2009-01-01.
but i'm getting the error as:-
"<?xml version="1.0"?>
<ErrorResponse xmlns="https://mws.amazonservices.com/">
<Error>
<Type>Sender</Type>
<Code>InvalidAddress</Code>
<Message>Resource /$metadata is not found on this server. API Version is missing</Message>
</Error>
<RequestID>c00cb653-f53c-445f-9f24-82587144805d</RequestID>
</ErrorResponse>
"
Please help me to resolve this.
Thank you
The error you are getting is InvalidAddress, not a signature check error. It seems whatever you are doing in step 3 (Post the data on Feed/2009-01-01) does not work as expected. The MWS servers see a request for /$metadata instead of API name and version. Your question does not include the piece of code that does that.
I am trying to use an API that is hosted externally and also returns JSON data. I have tried editing the headers but I'm not entirely sure it is working because I am still getting a warning about not having the CORS header
Source
var url = "http://hkconsult.in/social_search/keyword_services.php?keyword=throat&callback=test";
$.ajax({
type: 'get',
url: url,
headers: {
"Origin":"http://hkconsult.in/social_search/keyword_services.php?keyword=throat&callback=test",
"Access-Control-Allow-Origin":"http://hkconsult.in/social_search/keyword_services.php?keyword=throat&callback=test"
}
}).done(function(data) {
document.getElementById('cool').innerHTML = data;
});
Firebug Headers
When opening the response for the "OPTIONS" url in firebug, it returns the data that I want. How do I use that data in javascript?
The CORS are headers that the server should send you as a response to your request.
The OPTIONS request is performed by the browser to check those headers prior to performing your actual request.
You cannot get the result of that OPTIONS request because it happens outside the scope of your code.
If the server is not setup to send those headers, then your only option is to use a proxy page that will use a server-side script to perform the call on your behalf.
As per my understanding you are asking about how to parse the response JSON instead of CORS Issue.
var data = {
"0": {
"keyword_name": "Sore throat",
"id": "1787",
"user_id": "3350988339",
"user_name": "Nic",
"user_screen_name": "Goldendevi",
"user_profile_pic": "http://pbs.twimg.com/profile_images/840766770633945088/eRRoRZHv_normal.jpg",
"user_location": "",
"post_id": "864553159896838145",
"post_text": "I'm so mad I have a fucking sore throat 🙄",
"post_geo_location": "0",
"post_image": "",
"post_date": "2017-05-16 20:48:30"
},
"1": {
"keyword_name": "Sore throat",
"id": "1788",
"user_id": "63496454",
"user_name": "mariana",
"user_screen_name": "yugyeumie",
"user_profile_pic": "http://pbs.twimg.com/profile_images/863802594132733952/ep0DtSoT_normal.jpg",
"user_location": "jjp; ë§ ìŠ¨",
"post_id": "864552988974747649",
"post_text": "is it possible to die of a sore throat",
"post_geo_location": "0",
"post_image": "",
"post_date": "2017-05-16 20:47:49"
}
};
var res = Object.keys(data).map(item => {return data[item].keyword_name });
console.log(res);
I am working with Meteor.js. I need place photos of google place. I am working with Javascript here. So here is what I've done.
Meteor.call('getPlaceDetails', result.place_id, function (error, placeDetailsResult) {
if (error) {
console.log(error);
} else {
console.log(placeDetailsResult.data.result.photos[0].photo_reference);
Meteor.call('getPlacePhotos', placeDetailsResult.data.result.photos[0].photo_reference, function (error, photoresult) {
if (error) {
console.log(error);
} else {
console.log(photoresult);
}
});
}
});
I successfully got place_id from Place Details API call. With place_id I can then again successfully call the Place Photos API. I think all goes well here. In response I should get the photo and this is my responded JSON object:
Object {statusCode: 200, content: "����JFIF��*ExifII*1…!�o~Ç����`��&]<sP�\U��TV-���##�{��8�#7��*�"���", headers: Object, data: null}
content
:
"����JFIF��*ExifII*1Google���↵ ↵↵↵↵↵
data
:
null
headers
:
Object
access-control-allow-origin
:
"*"
access-control-expose-headers
:
"Content-Length"
alt-svc
:
"quic=":443"; ma=2592000; v="36,35,34,33,32,31,30""
alternate-protocol
:
"443:quic"
cache-control
:
"public, max-age=86400, no-transform"
connection
:
"close"
content-disposition
:
"inline;filename="2015-11-13.jpg""
content-length
:
"38587"
content-type
:
"image/jpeg"
date
:
"Thu, 01 Sep 2016 12:12:47 GMT"
etag
:
""v21fad""
expires
:
"Fri, 02 Sep 2016 12:12:47 GMT"
server
:
"fife"
vary
:
"Origin"
x-content-type-options
:
"nosniff"
x-xss-protection
:
"1; mode=block"
__proto__
:
Object
statusCode
:
200
__proto__
:
Object
In the documentation here: https://developers.google.com/places/web-service/photos they say you get a photo in return. So everything is fine, but I don't know how to display this photo on my website according there is no url. Please provide some usefull info.
Thanks :)
I did miss that function of what Sorin Lascu has commented. If someone is doing that in Meteor.js I will provide a complete and easy answer. I created an input field which has Google Maps API autocomplete, and shows the place on a map instantly. You also get all the necessary data you need to show to photos and other details.
I added this package jeremy:geocomplete to my project.
I created a map in HTML like this:
<div class="col s12 m10 l10 push-m1 push-l1" id="google_mapPlace">
{{> googleMap name="mapPlace" options=mapOptions}}
</div>
I added an input field in HTML
<input value="" type="text" class="findPlace">
Then in my js file I update my function with autorun.
Template.adminCollections.onRendered(function() {
this.autorun(function () {
if (GoogleMaps.loaded()) {
$(".findPlace").geocomplete({
map: "#google_mapPlace",
nearbySearchKeys: ['photos', 'place_id', 'name', 'geometry']
}).bind("geocode:result", function(event, result){
$('.myimg').attr('src', result.photos[0].getUrl({'maxWidth': 500, 'maxHeight': 500}));
});
});
});
});
I'm attempting to write an alternative UI for a website I commonly use. I'm writing it with Node.js using request and cheerio to scrape the web pages of data.
However, the problem occurs when I attempt to send a POST request against this site. I want to retrieve the list of classes here without going through this page first, but the normal post parameters shown in the devtools are structured like this:
sel_subj:dummy
bl_online:FALSE
sel_day:dummy
term:201630
sel_subj:ACTG
sel_inst:ANY
sel_online:
sel_crse:
begin_hh:0
begin_mi:0
end_hh:0
end_mi:0
I can modify any other value (term, sel_crse, etc), but the sel_subj doesn't have a compatible value, so the server just goes with the default value.
I've been trying different values for the form Object parameter in request, but none of these have worked:
sel_subj: ["M", "dummy"]
sel_subj: ["dummy", "M"]
sel_subj: "M"
sel_subj: "dummy,M"
sel_subj: "M,dummy"
sel_subj: "dummy M"
sel_subj: "M dummy"
sel_subj: "dummy, M"
sel_subj: "M, dummy"
I'm trying to figure out what a duplicate field in the POST request means, what the server expects, and how to reproduce that with request
If parameter names can be duplicated, the request body can be designed by yourself:
var headers = {'content-type' : 'application/x-www-form-urlencoded'};
var body = [];
var params = [
{ sel_subj:'dummy' }, // duplicates
{ bl_online:false },
{ sel_day:'dummy' },
{ term:'201630'},
{ sel_subj:'ACTG'}, // duplicates
{ sel_inst:'ANY'},
{ sel_online: null},
{ sel_crse: null},
{ begin_hh:0},
{ begin_mi:0},
{ end_hh:0},
{ end_mi:0}
];
params.forEach( function(p) {
body.push( require('querystring').stringify(p) );
});
var r = request.post({ url:'http://localhost/api/',
headers: headers,
body:body.join('&')
});