Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty line added to Batch Request body #285

Open
ramanareddy438 opened this issue Oct 16, 2024 · 2 comments · May be fixed by #291
Open

Empty line added to Batch Request body #285

ramanareddy438 opened this issue Oct 16, 2024 · 2 comments · May be fixed by #291

Comments

@ramanareddy438
Copy link

ramanareddy438 commented Oct 16, 2024

Hi Team,

I am using pyodata to batch upsert data into SuccessFactors OData API.

batch_req = sf_odata_service.create_batch()
change set = sf_odata_service.create_changeset()

cc_data = {
 "name_en_US": "Test",
 "description_en_US": "Test",
 "startDate": "/Date(-220898800000)/"
}

change_set.add_request(sf_odata_service.entity_sets.FOCostCenter.create_entity().set(**cc_data))

cc_data = {
 "name_en_US": "Dummy",
 "description_en_US": "Dummy",
 "startDate": "/Date(-220898800000)/"
}
change_set.add_request(sf_odata_service.entity_sets.FOCostCenter.create_entity().set(**cc_data))

batch_req.add_request(change_set)

batch_req.execute()

The above code is throwing Missing Boundary delimiter at line '4'.

I printed the body of the request.

--batch_3041_8524_1030
Content-Type: multipart/mixed;boundary=changeset_6522_8586_6718


--changeset_6522_8586_6718
Content-Type: application/http
Content-Transfer-Encoding:binary

POST FOCostCenter HTTP/1.1
Accept: application/json
Content-Type: application/json
X-Requested-With: X

{"startDate": "/Date(-2208988800000)/", "externalCode": "Dummy", "name_en_US": "Dummy", "name_defaultValue": "Dummy", "description_en_US": "", "description_defaultValue": "", "status": "A", "costcenterExternalObjectID": ""}
--changeset_6522_8586_6718
Content-Type: application/http
Content-Transfer-Encoding:binary

POST FOCostCenter HTTP/1.1
Accept: application/json
Content-Type: application/json
X-Requested-With: X

{"startDate": "/Date(1720656000000)/", "externalCode": "Test", "name_en_US": "Test", "name_defaultValue": "Test", "description_en_US": "", "description_defaultValue": "", "status": "A", "costcenterExternalObjectID": ""}
--changeset_6522_8586_6718--
--batch_3041_8524_1030

I see an extra space added after the Content-Type. Not sure where the issue is from myside. Any help is greatly appreciated.

@bpreissler
Copy link

In the file pyodata/v2/service.py in line 46
lines.extend(('Content-Type: application/http ', 'Content-Transfer-Encoding:binary'))
There is an unnecessary space after the Content-Type header. This is I think why there is a space after the content type. When I change that it works for me.
In contrast to your case I use an API Gateway where validation fails.

phanak-sap added a commit that referenced this issue Mar 14, 2025
@phanak-sap phanak-sap linked a pull request Mar 14, 2025 that will close this issue
@phanak-sap
Copy link
Contributor

Hi @bpreissler

thx for the investigation. That could be PR directly, sorry, i did not see activity on this issue and that you find the root cause.
I also misunderstand from the original comment where do you see the problem with one whitespace more than needed - e.g. Content-Type:Xapplication/http instead of Content-Type: application/httpX

This should be fixed, will do that.

out of curiosity - what do you mean by " I use an API Gateway where validation fails."? what api gateway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants